Improving birthday bonus.

master
Thomas Hintz 4 years ago
parent 6219e65e66
commit a38c55e877

@ -34,7 +34,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser, faUsers, faTractor, faWindowRestore, import { faUser, faUsers, faTractor, faWindowRestore,
faDollarSign, faTimes, faExchangeAlt, faDollarSign, faTimes, faExchangeAlt,
faInfoCircle, faArrowUp, faArrowDown, faAward, 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 { GroupBox, Row, Col, Button } from '../widgets.jsx'
import SpaceNode from './SpaceNode.jsx' import SpaceNode from './SpaceNode.jsx'
@ -49,7 +49,7 @@ import { buy, roll, endTurn, loan, trade, submitTradeAccept,
submitTradeDeny, submitTradeCancel, audit, submitTradeDeny, submitTradeCancel, audit,
buyUncleBert, skip, endAiTurn, startGame, readyToStart, buyUncleBert, skip, endAiTurn, startGame, readyToStart,
leaveGame, kickPlayer, toggleRevealForTrade, leaveGame, kickPlayer, toggleRevealForTrade,
addAIPlayer } from './interface.js' addAIPlayer, birthdayBonusPlayer } from './interface.js'
function netWorth(player) { function netWorth(player) {
return ((player.assets.hay + player.assets.grain) * 2000) + return ((player.assets.hay + player.assets.grain) * 2000) +
@ -121,10 +121,12 @@ class PlayerResources extends React.Component {
amount={player.assets.tractor}> amount={player.assets.tractor}>
{player.assets.tractor} {player.assets.tractor}
</ResourceUnit>{' '} </ResourceUnit>{' '}
<ResourceUnit img={CakeImg} h='240' s='100' label='Birthday' {player.assets.birthday ? (
amount={player.assets.birthday ? player.assets.birthday : 0}> <ResourceUnit img={CakeImg} h='240' s='100' label='Birthday'
{player.assets.birthday ? player.assets.birthday : 0} amount={player.assets.birthday ? player.assets.birthday : 0}>
</ResourceUnit> {player.assets.birthday ? player.assets.birthday : 0}
</ResourceUnit>
) : (<></>)}
</div> </div>
); );
} }
@ -1924,6 +1926,10 @@ const StartGame = ({ game, player, toggleReady }) => {
const playerName = player.name; const playerName = player.name;
const { color } = player; const { color } = player;
const { name, host } = game; const { name, host } = game;
const birthdayClass = (player) =>
player.assets.birthday ? 'birthday-selected' : '';
return ( return (
<> <>
<h1>Lobby</h1> <h1>Lobby</h1>
@ -1932,14 +1938,26 @@ const StartGame = ({ game, player, toggleReady }) => {
</p> </p>
<h3>Players</h3> <h3>Players</h3>
<ul> <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) => ( {game.otherPlayers.map((p, i) => (
<li key={i}> <li key={i}>
<PlayerColorIcon color={p.player.color} /> {p.player.name} <PlayerColorIcon color={p.player.color} /> {p.player.name}
{playerName === host ? ( {playerName === host ? (
<span title="Kick Player" className="kick-player" onClick={() => kickPlayer(p.player.name)}> <>
<FontAwesomeIcon icon={faBan} /> <span title="Kick Player" className="lobby-icon kick-player" onClick={() => kickPlayer(p.player.name)}>
</span> <FontAwesomeIcon icon={faBan} />
</span>
<span title="Birthday Bonus" className={"lobby-icon " + birthdayClass(p.player)} onClick={() => birthdayBonusPlayer(p.player.name)}>
<FontAwesomeIcon icon={faBirthdayCake} />
</span>
</>
): (<></>)} ): (<></>)}
</li> </li>
))} ))}

@ -32,7 +32,7 @@ export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
submitTradeDeny, submitTradeCancel, audit, handleMessage, submitTradeDeny, submitTradeCancel, audit, handleMessage,
nextAction, buyUncleBert, actionsFinished, skip, endAiTurn, nextAction, buyUncleBert, actionsFinished, skip, endAiTurn,
startGame, readyToStart, leaveGame, kickPlayer, toggleRevealForTrade, startGame, readyToStart, leaveGame, kickPlayer, toggleRevealForTrade,
addAIPlayer } addAIPlayer, birthdayBonusPlayer }
let store; let store;
let movingTimer = 0; let movingTimer = 0;
@ -218,6 +218,10 @@ function kickPlayer(name) {
sendCommand({ type: 'kick-player', name }); sendCommand({ type: 'kick-player', name });
} }
function birthdayBonusPlayer(name) {
sendCommand({ type: 'birthday-bonus-player', name });
}
function addAIPlayer() { function addAIPlayer() {
sendCommand({ type: 'add-ai-player' }); sendCommand({ type: 'add-ai-player' });
} }

@ -1606,6 +1606,17 @@
(safe-set! (player-ready-to-start (*player*)) (not (player-ready-to-start (*player*)))) (safe-set! (player-ready-to-start (*player*)) (not (player-ready-to-start (*player*))))
(message-players! (*game*) (*player*) '() type: "update") (message-players! (*game*) (*player*) '() type: "update")
(create-ws-response (*player*) "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") ((string=? type "kick-player")
(let ((kicked-player (find (lambda (p) (let ((kicked-player (find (lambda (p)
(equal? (player-name p) (alist-ref 'name msg))) (equal? (player-name p) (alist-ref 'name msg)))
@ -1641,6 +1652,10 @@
type: "player-left-game") type: "player-left-game")
(create-ws-response (*player*) "left-game" '())) (create-ws-response (*player*) "left-game" '()))
((string=? type "start-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) (safe-set! (game-state (*game*)) 'pre-turn)
(db-update-game (game-id (*game*)) (symbol->string (game-state (*game*))) (db-update-game (game-id (*game*)) (symbol->string (game-state (*game*)))
(game->sexp (*game*))) (game->sexp (*game*)))

@ -1051,11 +1051,16 @@ $intro-time: 6s;
position: absolute; position: absolute;
bottom: 1rem; } bottom: 1rem; }
.kick-player { .lobby-icon {
cursor: pointer; cursor: pointer;
color: red;
margin-left: 0.2rem; } margin-left: 0.2rem; }
.kick-player {
color: red; }
.birthday-selected {
color: blue; }
ul { ul {
margin-left: 0; margin-left: 0;
list-style-type: none; } list-style-type: none; }

Loading…
Cancel
Save