Merge branch 'cypress' into master
This commit is contained in:
@@ -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'
|
||||
|
||||
let showScreenDelay = 2000;
|
||||
|
||||
@@ -177,18 +177,18 @@ class PlayerResources extends React.Component {
|
||||
<ResourceUnit img={TractorImg} h='240' s='100' label='Tractors'
|
||||
amount={player.assets.tractor}>
|
||||
{player.assets.tractor}
|
||||
</ResourceUnit>
|
||||
</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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* {' '}
|
||||
* <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> */
|
||||
|
||||
// http://stackoverflow.com/questions/149055
|
||||
function formatMoney(n) {
|
||||
return n.toFixed(1).replace(/(\d)(?=(\d{3})+\.)/g, '$1,').slice(0, -2); }
|
||||
@@ -1949,21 +1949,23 @@ class AlertOverlay extends React.Component {
|
||||
<FontAwesomeIcon icon={faTimes} />
|
||||
</div>
|
||||
) : (<></>)}
|
||||
<div className='alert-overlay-contents'>
|
||||
{this.props.children}
|
||||
<br />
|
||||
<div>
|
||||
<Button onClick={this.buttonClick} disabled={!!this.props.disabled}>{this.props.buttonText}</Button>
|
||||
{this.props.cancelButtonText ? (
|
||||
<>
|
||||
{' '}
|
||||
<Button onClick={this.cancelButtonClick} disabled={!!this.props.cancelDisabled}>
|
||||
{this.props.cancelButtonText}
|
||||
</Button>
|
||||
</>
|
||||
): (<></>)}
|
||||
<div className='alert-container'>
|
||||
<div className='alert-overlay-contents'>
|
||||
{this.props.children}
|
||||
<br />
|
||||
<div>
|
||||
<Button onClick={this.buttonClick} disabled={!!this.props.disabled}>{this.props.buttonText}</Button>
|
||||
{this.props.cancelButtonText ? (
|
||||
<>
|
||||
{' '}
|
||||
<Button onClick={this.cancelButtonClick} disabled={!!this.props.cancelDisabled}>
|
||||
{this.props.cancelButtonText}
|
||||
</Button>
|
||||
</>
|
||||
): (<></>)}
|
||||
</div>
|
||||
{!this.props.preventHiding ? (<a onClick={this.hide}>close</a>) : (<></>)}
|
||||
</div>
|
||||
{!this.props.preventHiding ? (<a onClick={this.hide}>close</a>) : (<></>)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -2055,54 +2057,68 @@ class Info extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
class StartGame extends React.Component {
|
||||
render() {
|
||||
const { auditThreshold, downPayment, loanInterest, maxDebt, startingOtbs, startingCash, startingDebt } = this.props.game.settings;
|
||||
const playerName = this.props.player.name;
|
||||
const { color } = this.props.player;
|
||||
const { name, host } = this.props.game;
|
||||
return (
|
||||
<>
|
||||
<h1>Lobby</h1>
|
||||
<p>
|
||||
<b>Game</b>: {name}
|
||||
</p>
|
||||
<h3>Players</h3>
|
||||
<ul>
|
||||
<li><PlayerColorIcon color={color} /> {playerName}</li>
|
||||
{this.props.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)}>
|
||||
const StartGame = ({ game, player, toggleReady }) => {
|
||||
const { auditThreshold, downPayment, loanInterest, maxDebt, startingOtbs, startingCash, startingDebt } = game.settings;
|
||||
const playerName = player.name;
|
||||
const { color } = player;
|
||||
const { name, host } = game;
|
||||
|
||||
const birthdayClass = (player) =>
|
||||
player.assets.birthday ? 'birthday-selected' : '';
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>Lobby</h1>
|
||||
<p>
|
||||
<b>Game</b>: {name}
|
||||
</p>
|
||||
<h3>Players</h3>
|
||||
<ul>
|
||||
<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="lobby-icon kick-player" onClick={() => kickPlayer(p.player.name)}>
|
||||
<FontAwesomeIcon icon={faBan} />
|
||||
</span>
|
||||
): (<></>)}
|
||||
</li>
|
||||
))}
|
||||
<li>
|
||||
<span className="add-ai" onClick={addAIPlayer}>
|
||||
<FontAwesomeIcon icon={faPlusCircle} />AI
|
||||
</span>
|
||||
<span title="Birthday Bonus" className={"lobby-icon " + birthdayClass(p.player)} onClick={() => birthdayBonusPlayer(p.player.name)}>
|
||||
<FontAwesomeIcon icon={faBirthdayCake} />
|
||||
</span>
|
||||
</>
|
||||
): (<></>)}
|
||||
</li>
|
||||
</ul>
|
||||
<h4>Game Settings</h4>
|
||||
<ul>
|
||||
<li><b>Audit Threshold</b>: ${formatMoney(auditThreshold)}</li>
|
||||
<li><b>Max Debt</b>: ${formatMoney(maxDebt)}</li>
|
||||
<li><b>Loan Interest</b>: {loanInterest * 100}%</li>
|
||||
<li><b>Required Down Payment</b>: {downPayment * 100}%</li>
|
||||
<li><b>Starting {itemCardShort}</b>: {startingOtbs}</li>
|
||||
<li><b>Starting Cash</b>: ${formatMoney(startingCash)}</li>
|
||||
<li><b>Starting Debt</b>: ${formatMoney(startingDebt)}</li>
|
||||
</ul>
|
||||
<label>
|
||||
<input type="checkbox" onChange={this.props.toggleReady} />
|
||||
Ready to start
|
||||
</label>
|
||||
</>
|
||||
);
|
||||
}
|
||||
))}
|
||||
<li>
|
||||
<span className="add-ai" onClick={addAIPlayer}>
|
||||
<FontAwesomeIcon icon={faPlusCircle} />AI
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<h4>Game Settings</h4>
|
||||
<ul>
|
||||
<li><b>Audit Threshold</b>: ${formatMoney(auditThreshold)}</li>
|
||||
<li><b>Max Debt</b>: ${formatMoney(maxDebt)}</li>
|
||||
<li><b>Loan Interest</b>: {loanInterest * 100}%</li>
|
||||
<li><b>Required Down Payment</b>: {downPayment * 100}%</li>
|
||||
<li><b>Starting {itemCardShort}</b>: {startingOtbs}</li>
|
||||
<li><b>Starting Cash</b>: ${formatMoney(startingCash)}</li>
|
||||
<li><b>Starting Debt</b>: ${formatMoney(startingDebt)}</li>
|
||||
</ul>
|
||||
<label>
|
||||
<input type="checkbox" onChange={toggleReady} />
|
||||
Ready to start
|
||||
</label>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const SCREENS = { summary: 'summary', misc: 'misc', farms: 'farms',
|
||||
@@ -2246,7 +2262,7 @@ class BoardApp extends React.Component {
|
||||
buttonText='Close'
|
||||
hideHandler={() => 'nothing'}
|
||||
handler={() => { return false; }}>
|
||||
<Fragment>
|
||||
<div className="game-over">
|
||||
<h1>Game Over!</h1>
|
||||
{alert.contents.results.map((e, i) => (
|
||||
<p key={i}>{e}</p>
|
||||
@@ -2257,7 +2273,14 @@ class BoardApp extends React.Component {
|
||||
<p>{alert.contents.stats.emergency}</p>
|
||||
<p>{alert.contents.stats.highRoller}</p>
|
||||
<p>{alert.contents.stats.lowRoller}</p>
|
||||
</Fragment>
|
||||
{alert.contents.stats.players.map(p => (
|
||||
<div key={p.name}>
|
||||
<p><b>{p.name} Harvests:</b></p>
|
||||
<p>Total: ${formatMoney(p.harvestTotal)} Expenses: ${formatMoney(Math.abs(p.operatingExpenses))}</p>
|
||||
<p>Avg ${formatMoney(p.harvestAverage)} rolling {p.harvestRoll} for {p.numHarvests} harvests</p>
|
||||
<p>Hay: ${formatMoney(p.hay)} Grain: ${formatMoney(p.grain)} Fruit: ${formatMoney(p.fruit)} Cows: ${formatMoney(p.cows)}</p>
|
||||
</div>))}
|
||||
</div>
|
||||
</AlertOverlay>
|
||||
);
|
||||
} else if (alert && alert.type === ALERTS.auditCalled) {
|
||||
|
||||
@@ -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' });
|
||||
}
|
||||
|
||||
@@ -180,7 +180,12 @@
|
||||
(tax-person . 0)
|
||||
(emergency . 0)
|
||||
(num-harvests . 0)
|
||||
(harvest-rolls . 0)))
|
||||
(harvest-rolls . 0)
|
||||
(operating-expenses . 0)
|
||||
(hay . 0)
|
||||
(grain . 0)
|
||||
(fruit . 0)
|
||||
(cows . 0)))
|
||||
(alist-ref 'ai? args eqv? #f)
|
||||
(alist-ref 'processing-turn args eqv? #f))))
|
||||
|
||||
@@ -563,7 +568,7 @@
|
||||
;; (session-set! (sid) 'game *game*)
|
||||
;; (set-startup-otbs (session-ref (sid) 'player) 2)
|
||||
)
|
||||
(send-static-file "main.html")
|
||||
(send-static-file "index.html")
|
||||
;; (with-headers `((connection close)
|
||||
;; (content-type text/html))
|
||||
;; (lambda ()
|
||||
@@ -1023,7 +1028,31 @@
|
||||
(* (/ (alist-ref 'harvest-rolls (player-stats p))
|
||||
(max (alist-ref 'num-harvests (player-stats p)) 1))
|
||||
10))
|
||||
10)) ")"))))))
|
||||
10)) ")")))
|
||||
(players . ,(list->vector
|
||||
(map (lambda (p)
|
||||
(let ((stats (player-stats p)))
|
||||
`((name . ,(player-name p))
|
||||
(numHarvests . ,(alist-ref 'num-harvests stats))
|
||||
(hay . ,(alist-ref 'hay stats))
|
||||
(grain . ,(alist-ref 'grain stats))
|
||||
(fruit . ,(alist-ref 'fruit stats))
|
||||
(cows . ,(alist-ref 'cows stats))
|
||||
(harvestAverage . ,(exact->inexact
|
||||
(round
|
||||
(/ (fold + 0 (map (lambda (c) (alist-ref c stats))
|
||||
'(hay grain fruit cows)))
|
||||
(alist-ref 'num-harvests stats)))))
|
||||
(harvestTotal . ,(fold + 0 (map (lambda (c) (alist-ref c stats))
|
||||
'(hay grain fruit cows))))
|
||||
(operatingExpenses . ,(alist-ref 'operating-expenses stats))
|
||||
(harvestRoll . ,(exact->inexact
|
||||
(/ (round
|
||||
(* (/ (alist-ref 'harvest-rolls stats)
|
||||
(max (alist-ref 'num-harvests stats) 1))
|
||||
10))
|
||||
10))))))
|
||||
(game-players game)))))))
|
||||
type: "end-of-game")))
|
||||
|
||||
(define (create-ws-response player event misc)
|
||||
@@ -1588,6 +1617,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)))
|
||||
@@ -1623,6 +1663,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*)))
|
||||
@@ -2348,7 +2392,7 @@
|
||||
(define (make-player-stat stat amount)
|
||||
(lambda (p)
|
||||
(safe-set! (player-stats p)
|
||||
(alist-update stat (+ (alist-ref stat (player-stats p)) amount)
|
||||
(alist-update stat (+ (alist-ref stat (player-stats p) eqv? 0) amount)
|
||||
(player-stats p)))))
|
||||
|
||||
(define (get-actions player space)
|
||||
@@ -2572,6 +2616,7 @@
|
||||
(begin
|
||||
((make-player-stat 'num-harvests 1) player)
|
||||
((make-player-stat 'harvest-rolls rolled) player)
|
||||
((make-player-stat crop income) player)
|
||||
(safe-set! (player-cash player)
|
||||
(+ (player-cash player) income))
|
||||
(safe-set! (player-harvest-mult player) 1)
|
||||
@@ -2585,6 +2630,9 @@
|
||||
(player-name player))))
|
||||
(game-players game)))))
|
||||
((alist-ref 'action operating-expense) player)
|
||||
((make-player-stat 'operating-expenses
|
||||
(- (player-cash player) previous-cash))
|
||||
player)
|
||||
`((rolled . ,rolled)
|
||||
(rolls . ,(list->vector (make-rolls 22)))
|
||||
(income . ,income)
|
||||
|
||||
@@ -919,8 +919,6 @@ $trade-margin: 3rem;
|
||||
color: white; }
|
||||
|
||||
.alert-overlay-contents {
|
||||
max-height: 90vh;
|
||||
overflow: auto;
|
||||
background: $light-color;
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
@@ -928,6 +926,10 @@ $trade-margin: 3rem;
|
||||
justify-content: center;
|
||||
align-items: center; }
|
||||
|
||||
.alert-container {
|
||||
max-height: 90vh;
|
||||
overflow: auto; }
|
||||
|
||||
.moving {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -1049,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; }
|
||||
@@ -1062,3 +1069,9 @@ ul {
|
||||
font-family: 'IndieFlower-Regular';
|
||||
width: 0;
|
||||
height: 0; }
|
||||
|
||||
.game-over p {
|
||||
margin-bottom: 0.2rem;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user