Syncing displayed cash with actions.

This commit is contained in:
2020-03-31 09:08:57 -07:00
parent 93cc806eb2
commit 41b30fa314
3 changed files with 55 additions and 18 deletions

View File

@@ -50,7 +50,7 @@ function netWorth(player) {
(player.assets.fruit * 5000) +
(player.assets.cows * 500) +
((player.assets.harvester + player.assets.tractor) * 10000) +
player.cash - player.debt;
player.displayCash - player.debt;
}
function assetsValue(player) {
@@ -285,7 +285,7 @@ class PlayerSummary extends React.Component {
return (
<GroupBox title={(<Fragment><div className={'player player-' + player.color}></div> {player.name}
</Fragment>)}>
<MoneySummary title='Cash' value={player.cash} /> {' '}
<MoneySummary title='Cash' value={player.displayCash} /> {' '}
<MoneySummary title='Debt' value={player.debt} /> {' '}
<br /><br />
<MoneySummary title='Assets' value={assetsValue(player)} /> {' '}
@@ -539,7 +539,7 @@ class Loans extends React.Component {
takeOut = value * 1000;
}
this.setState({ repay: Math.max(0, Math.floor(
Math.min(repay, this.props.player.debt + 900, this.props.player.cash) / 1000)),
Math.min(repay, this.props.player.debt + 900, this.props.player.displayCash) / 1000)),
takeOut: Math.max(0, Math.floor(
Math.min(takeOut, this.state.maxLoan) / 1000)) });
}
@@ -566,7 +566,7 @@ class Loans extends React.Component {
render () {
return (
<GroupBox title={'Loans'}>
<MoneySummary title='Cash' value={this.props.player.cash} /> {' '}
<MoneySummary title='Cash' value={this.props.player.displayCash} /> {' '}
<MoneySummary title='Debt' value={this.props.player.debt} />
/${formatMoney(this.props.game.settings.maxDebt)}
<br />
@@ -1681,12 +1681,12 @@ class BoardApp extends React.Component {
<div>
<Card ui={this.props.ui}
setCardError={this.props.setCardError}
playerCash={this.props.player.cash}
playerCash={this.props.player.displayCash}
playerDebt={this.props.player.debt}
card={this.state.card}
cost={this.state.card.total / 1000}
min={(this.state.card.total * this.props.game.settings.downPayment) / 1000}
max={Math.floor(Math.min(this.props.player.cash / 1000, this.state.card.total / 1000))}
max={Math.floor(Math.min(this.props.player.displayCash / 1000, this.state.card.total / 1000))}
cash={(this.state.card.total * this.props.game.settings.downPayment) / 1000} />
</div>
</Col>

View File

@@ -82,6 +82,7 @@ const spaces =
const initialState = {
player: { cash: 5000,
displayCash: 5000,
lastCash: 5000,
debt: 5000,
spaces,