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,
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>
))}

@ -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' });
}

@ -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*)))

@ -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; }

Loading…
Cancel
Save