summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hintz <t@thintz.com>2020-08-28 12:19:37 -0700
committerThomas Hintz <t@thintz.com>2020-08-28 12:19:37 -0700
commita38c55e877b86233349f8b9ff3ba0038df37a906 (patch)
tree999f513fdbb3e822633eafe77ffe4999cdcf71d5
parent6219e65e66f5871c034220d240778ffc61e15e6b (diff)
downloadfarm-a38c55e877b86233349f8b9ff3ba0038df37a906.tar.gz
Improving birthday bonus.
-rw-r--r--src/components/farm/Board.jsx38
-rw-r--r--src/components/farm/interface.js6
-rw-r--r--src/server/farm.scm15
-rw-r--r--src/style.scss9
4 files changed, 55 insertions, 13 deletions
diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx
index 6a11145..7eef1bb 100644
--- a/src/components/farm/Board.jsx
+++ b/src/components/farm/Board.jsx
@@ -34,7 +34,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser, faUsers, faTractor, faWindowRestore,
faDollarSign, faTimes, faExchangeAlt,
faInfoCircle, faArrowUp, faArrowDown, faAward,
- faBan, faArrowCircleLeft, faPlusCircle } from '@fortawesome/free-solid-svg-icons'
+ faBan, faArrowCircleLeft, faPlusCircle, faBirthdayCake } from '@fortawesome/free-solid-svg-icons'
import { GroupBox, Row, Col, Button } from '../widgets.jsx'
import SpaceNode from './SpaceNode.jsx'
@@ -49,7 +49,7 @@ import { buy, roll, endTurn, loan, trade, submitTradeAccept,
submitTradeDeny, submitTradeCancel, audit,
buyUncleBert, skip, endAiTurn, startGame, readyToStart,
leaveGame, kickPlayer, toggleRevealForTrade,
- addAIPlayer } from './interface.js'
+ addAIPlayer, birthdayBonusPlayer } from './interface.js'
function netWorth(player) {
return ((player.assets.hay + player.assets.grain) * 2000) +
@@ -121,10 +121,12 @@ class PlayerResources extends React.Component {
amount={player.assets.tractor}>
{player.assets.tractor}
</ResourceUnit>{' '}
- <ResourceUnit img={CakeImg} h='240' s='100' label='Birthday'
- amount={player.assets.birthday ? player.assets.birthday : 0}>
- {player.assets.birthday ? player.assets.birthday : 0}
- </ResourceUnit>
+ {player.assets.birthday ? (
+ <ResourceUnit img={CakeImg} h='240' s='100' label='Birthday'
+ amount={player.assets.birthday ? player.assets.birthday : 0}>
+ {player.assets.birthday ? player.assets.birthday : 0}
+ </ResourceUnit>
+ ) : (<></>)}
</div>
);
}
@@ -1924,6 +1926,10 @@ const StartGame = ({ game, player, toggleReady }) => {
const playerName = player.name;
const { color } = player;
const { name, host } = game;
+
+ const birthdayClass = (player) =>
+ player.assets.birthday ? 'birthday-selected' : '';
+
return (
<>
<h1>Lobby</h1>
@@ -1932,14 +1938,26 @@ const StartGame = ({ game, player, toggleReady }) => {
</p>
<h3>Players</h3>
<ul>
- <li><PlayerColorIcon color={color} /> {playerName}</li>
+ <li>
+ <PlayerColorIcon color={color} /> {playerName}
+ {playerName === host ? (
+ <span title="Birthday Bonus" className={'lobby-icon ' + birthdayClass(player)} onClick={() => birthdayBonusPlayer(playerName)}>
+ <FontAwesomeIcon icon={faBirthdayCake} />
+ </span>
+ ) : (<></>)}
+ </li>
{game.otherPlayers.map((p, i) => (
<li key={i}>
<PlayerColorIcon color={p.player.color} /> {p.player.name}
{playerName === host ? (
- <span title="Kick Player" className="kick-player" onClick={() => kickPlayer(p.player.name)}>
- <FontAwesomeIcon icon={faBan} />
- </span>
+ <>
+ <span title="Kick Player" className="lobby-icon kick-player" onClick={() => kickPlayer(p.player.name)}>
+ <FontAwesomeIcon icon={faBan} />
+ </span>
+ <span title="Birthday Bonus" className={"lobby-icon " + birthdayClass(p.player)} onClick={() => birthdayBonusPlayer(p.player.name)}>
+ <FontAwesomeIcon icon={faBirthdayCake} />
+ </span>
+ </>
): (<></>)}
</li>
))}
diff --git a/src/components/farm/interface.js b/src/components/farm/interface.js
index b297540..a78c3ad 100644
--- a/src/components/farm/interface.js
+++ b/src/components/farm/interface.js
@@ -32,7 +32,7 @@ export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
submitTradeDeny, submitTradeCancel, audit, handleMessage,
nextAction, buyUncleBert, actionsFinished, skip, endAiTurn,
startGame, readyToStart, leaveGame, kickPlayer, toggleRevealForTrade,
- addAIPlayer }
+ addAIPlayer, birthdayBonusPlayer }
let store;
let movingTimer = 0;
@@ -218,6 +218,10 @@ function kickPlayer(name) {
sendCommand({ type: 'kick-player', name });
}
+function birthdayBonusPlayer(name) {
+ sendCommand({ type: 'birthday-bonus-player', name });
+}
+
function addAIPlayer() {
sendCommand({ type: 'add-ai-player' });
}
diff --git a/src/server/farm.scm b/src/server/farm.scm
index d549536..1e3cce9 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -1606,6 +1606,17 @@
(safe-set! (player-ready-to-start (*player*)) (not (player-ready-to-start (*player*))))
(message-players! (*game*) (*player*) '() type: "update")
(create-ws-response (*player*) "update" '()))
+ ((string=? type "birthday-bonus-player")
+ (let ((player (find (lambda (p)
+ (equal? (player-name p) (alist-ref 'name msg)))
+ (game-players (*game*)))))
+ (if (> (alist-ref 'birthday (player-assets player)) 0)
+ (set! (player-assets player)
+ (alist-update 'birthday 0 (player-assets player)))
+ (set! (player-assets player)
+ (alist-update 'birthday 1 (player-assets player))))
+ (message-players! (*game*) (*player*) '() type: "update")
+ (create-ws-response (*player*) "update" '())))
((string=? type "kick-player")
(let ((kicked-player (find (lambda (p)
(equal? (player-name p) (alist-ref 'name msg)))
@@ -1641,6 +1652,10 @@
type: "player-left-game")
(create-ws-response (*player*) "left-game" '()))
((string=? type "start-game")
+ (for-each (lambda (p)
+ (when (> (alist-ref 'birthday (player-assets p)) 0)
+ (set-startup-otbs (*game*) p 3)))
+ (game-players (*game*)))
(safe-set! (game-state (*game*)) 'pre-turn)
(db-update-game (game-id (*game*)) (symbol->string (game-state (*game*)))
(game->sexp (*game*)))
diff --git a/src/style.scss b/src/style.scss
index c921303..95dc634 100644
--- a/src/style.scss
+++ b/src/style.scss
@@ -1051,11 +1051,16 @@ $intro-time: 6s;
position: absolute;
bottom: 1rem; }
-.kick-player {
+.lobby-icon {
cursor: pointer;
- color: red;
margin-left: 0.2rem; }
+.kick-player {
+ color: red; }
+
+.birthday-selected {
+ color: blue; }
+
ul {
margin-left: 0;
list-style-type: none; }