summaryrefslogtreecommitdiffstats
path: root/src/components/farm/Board.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/farm/Board.jsx')
-rw-r--r--src/components/farm/Board.jsx87
1 files changed, 71 insertions, 16 deletions
diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx
index f9a3143..74386ee 100644
--- a/src/components/farm/Board.jsx
+++ b/src/components/farm/Board.jsx
@@ -47,7 +47,8 @@ import { setSelectedCard, setMessagePanelSpace, setMPDims, movePlayer,
setMovingSkip } from './actions.js'
import { buy, roll, endTurn, loan, trade, submitTradeAccept,
submitTradeDeny, submitTradeCancel, audit,
- buyUncleBert, skip, endAiTurn, startGame } from './interface.js'
+ buyUncleBert, skip, endAiTurn, startGame, readyToStart,
+ leaveGame } from './interface.js'
function netWorth(player) {
return ((player.assets.hay + player.assets.grain) * 2000) +
@@ -1810,6 +1811,11 @@ class AlertOverlay extends React.Component {
this.hide(e);
this.props.handler();
}
+
+ cancelButtonClick = e => {
+ e.preventDefault();
+ this.props.cancelHandler();
+ }
// <label><input type='checkbox' onClick={this.hidePermanent} /> {`Don't show again`}</label>
render() {
@@ -1823,7 +1829,17 @@ class AlertOverlay extends React.Component {
<div className='alert-overlay-contents'>
{this.props.children}
<br />
- <Button onClick={this.buttonClick}>{this.props.buttonText}</Button>
+ <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>
</div>
@@ -1916,6 +1932,44 @@ class Info extends React.Component {
}
}
+class StartGame extends React.Component {
+ render() {
+ const { auditThreshold, downPayment, loanInterest, maxDebt, startingOtbs, startingCash, startingDebt } = this.props.game.settings;
+ const { name } = this.props.game;
+ return (
+ <>
+ <h1>Lobby</h1>
+ <p>
+ <b>Game</b>: {name}
+ </p>
+ <h3>Players</h3>
+ <ul>
+ <li>{this.props.player.name}</li>
+ {this.props.game.otherPlayers.map((p, i) => (
+ <li key={i}>
+ {p.player.name}
+ </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>: ${formatMoney(downPayment)}</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>
+ </>
+ );
+ }
+}
+
const SCREENS = { summary: 'summary', misc: 'misc', farms: 'farms',
cards: 'cards', trade: 'trade', loans: 'loans',
action: 'action', info: 'info', error: 'error' };
@@ -1933,7 +1987,8 @@ class BoardApp extends React.Component {
screen: SCREENS.summary,
card: props.ui.card,
timerId: false,
- currentPlayer: this.props.player
+ currentPlayer: this.props.player,
+ readyToStart: false
};
this.myRef = React.createRef();
this.actionRef = React.createRef();
@@ -2038,6 +2093,11 @@ class BoardApp extends React.Component {
}
}
+ startGameToggleReady = () => {
+ this.setState(state => { return { readyToStart: !state.readyToStart }; });
+ readyToStart();
+ }
+
render() {
let alertOverlay;
const alert = this.props.ui.unhandledAlert;
@@ -2079,21 +2139,16 @@ class BoardApp extends React.Component {
alertHandled={this.props.alertHandled}
buttonText='Start Game'
hideHandler={() => 'nothing'}
+ cancelButtonText='Leave Game'
+ cancelHandler={leaveGame}
+ cancelDisabled={this.state.readyToStart}
preventHiding={true}
+ disabled={!this.props.game.readyToStart}
handler={startGame}>
- <Fragment>
- <h1>Pre Game</h1>
- <p>When all players have joined click 'Start Game'!</p>
- <h3>Players</h3>
- <ul>
- <li>{this.props.player.name}</li>
- {this.props.game.otherPlayers.map((p, i) => (
- <li key={i}>
- {p.player.name}
- </li>
- ))}
- </ul>
- </Fragment>
+ <StartGame player={this.props.player}
+ game={this.props.game}
+ toggleReady={this.startGameToggleReady}
+ />
</AlertOverlay>
);
} else if (alert && alert.type === ALERTS.proposedTrade) {