Showing crop multipliers, loan UX enhancement.

logins
Thomas Hintz 5 years ago
parent 41b30fa314
commit 6916991455

@ -31,7 +31,7 @@ import { connect } from 'react-redux'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faUser, faUsers, faTractor, faWindowRestore, import { faUser, faUsers, faTractor, faWindowRestore,
faDollarSign, faTimes, faAsterisk, faExchangeAlt, faDollarSign, faTimes, faAsterisk, faExchangeAlt,
faInfoCircle } from '@fortawesome/free-solid-svg-icons' faInfoCircle, faArrowUp } 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'
@ -47,17 +47,17 @@ import { buy, roll, endTurn, loan, trade, submitTradeAccept,
function netWorth(player) { function netWorth(player) {
return ((player.assets.hay + player.assets.grain) * 2000) + return ((player.assets.hay + player.assets.grain) * 2000) +
(player.assets.fruit * 5000) + (player.assets.fruit * 5000) +
(player.assets.cows * 500) + (player.assets.cows * 500) +
((player.assets.harvester + player.assets.tractor) * 10000) + ((player.assets.harvester + player.assets.tractor) * 10000) +
player.displayCash - player.debt; player.displayCash - player.debt;
} }
function assetsValue(player) { function assetsValue(player) {
return ((player.assets.hay + player.assets.grain) * 2000) + return ((player.assets.hay + player.assets.grain) * 2000) +
(player.assets.fruit * 5000) + (player.assets.fruit * 5000) +
(player.assets.cows * 500) + (player.assets.cows * 500) +
((player.assets.harvester + player.assets.tractor) * 10000); ((player.assets.harvester + player.assets.tractor) * 10000);
} }
function getElementValue(id) { function getElementValue(id) {
@ -120,10 +120,10 @@ class PlayerTradeProposed extends React.Component {
return (<p>You GAIN something if it is POSITIVE and you GIVE something if it is NEGATIVE.</p>); return (<p>You GAIN something if it is POSITIVE and you GIVE something if it is NEGATIVE.</p>);
} else if (this.props.player.trade.originator === this.props.player.name) { } else if (this.props.player.trade.originator === this.props.player.name) {
return (<p>You proposed a trade with <b>{this.props.player.trade.player}</b> for return (<p>You proposed a trade with <b>{this.props.player.trade.player}</b> for
{'\u00A0'}<b>{tradeString(this.props.player, false)}</b>.</p>); {'\u00A0'}<b>{tradeString(this.props.player, false)}</b>.</p>);
} else { } else {
return (<p><b>{this.props.player.trade.originator}</b> proposed a trade for return (<p><b>{this.props.player.trade.originator}</b> proposed a trade for
{'\u00A0'}<b>{tradeString(this.props.player, true)}</b>.</p>); {'\u00A0'}<b>{tradeString(this.props.player, true)}</b>.</p>);
} }
} }
} }
@ -161,11 +161,11 @@ class PlayerTradeButton extends React.Component {
return (<Button className='tiny' type='submit'>{text} Trade</Button>); return (<Button className='tiny' type='submit'>{text} Trade</Button>);
} else { } else {
return (<Fragment> return (<Fragment>
<Button className='tiny' type='submit'>{text} Trade</Button> <Button className='tiny' type='submit'>{text} Trade</Button>
<Button className='tiny' onClick={this.tradeDeny}> <Button className='tiny' onClick={this.tradeDeny}>
Deny Trade Deny Trade
</Button> </Button>
</Fragment>); </Fragment>);
} }
} }
} }
@ -177,9 +177,12 @@ class ResourceUnit extends React.Component {
<div className='resource-unit' <div className='resource-unit'
title={this.props.amount + ' ' + this.props.label} title={this.props.amount + ' ' + this.props.label}
style={{backgroundColor: hslString + '%, 85%)', style={{backgroundColor: hslString + '%, 85%)',
borderTop: '3px solid ' + hslString + '%, 55%)'}}> borderTop: '3px solid ' + hslString + '%, 55%)'}}>
{this.props.img ? (<img src={this.props.img} />) : (<Fragment />)} {this.props.img ? (<img src={this.props.img} />) : (<Fragment />)}
{this.props.children} {this.props.children}
{this.props.doubled ? (
<p>x2!</p>
) : (<></>)}
</div> </div>
); );
} }
@ -189,79 +192,83 @@ class PlayerTradeResources extends React.Component {
render () { render () {
let player = this.props.player; let player = this.props.player;
return (<form onSubmit={e => tradeFormSubmit(e, player)}> return (<form onSubmit={e => tradeFormSubmit(e, player)}>
<div className='player-trade-resources'> <div className='player-trade-resources'>
<ResourceUnit h='120' s='100' label='acres of Hay' amount={''}> <ResourceUnit h='120' s='100' label='acres of Hay' amount={''}>
<input type='number' id='trade-hay' defaultValue='0' /></ResourceUnit> {' '} <input type='number' id='trade-hay' defaultValue='0' /></ResourceUnit> {' '}
<ResourceUnit h='41' s='100' label='acres of Grain' amount={''}> <ResourceUnit h='41' s='100' label='acres of Grain' amount={''}>
<input type='number' id='trade-grain' defaultValue='0' /></ResourceUnit> {' '} <input type='number' id='trade-grain' defaultValue='0' /></ResourceUnit> {' '}
<ResourceUnit h='0' s='100' label='acres of Fruit' amount={''}> <ResourceUnit h='0' s='100' label='acres of Fruit' amount={''}>
<input type='number' id='trade-fruit' defaultValue='0' /></ResourceUnit> {' '} <input type='number' id='trade-fruit' defaultValue='0' /></ResourceUnit> {' '}
<ResourceUnit h='0' s='59' label='head of Cows' amount={''}> <ResourceUnit h='0' s='59' label='head of Cows' amount={''}>
<input type='number' id='trade-cows' defaultValue='0' /></ResourceUnit> {' '} <input type='number' id='trade-cows' defaultValue='0' /></ResourceUnit> {' '}
<ResourceUnit h='240' s='100' label='Harvesters' amount={''}> <ResourceUnit h='240' s='100' label='Harvesters' amount={''}>
<input type='number' id='trade-harvesters' defaultValue='0' /></ResourceUnit> {' '} <input type='number' id='trade-harvesters' defaultValue='0' /></ResourceUnit> {' '}
<ResourceUnit h='240' s='100' label='Tractors' amount={''}> <ResourceUnit h='240' s='100' label='Tractors' amount={''}>
<input type='number' id='trade-tractors' defaultValue='0' /></ResourceUnit> <input type='number' id='trade-tractors' defaultValue='0' /></ResourceUnit>
<br /><br /> <br /><br />
<b>Ridges</b>: <b>{ridgeNames[0][0]}</b>: <input type='checkbox' id='trade-ridge1' />{'\u00A0'} <b>Ridges</b>: <b>{ridgeNames[0][0]}</b>: <input type='checkbox' id='trade-ridge1' />{'\u00A0'}
<b>R</b>: <input type='checkbox' id='trade-ridge2' />{'\u00A0'} <b>R</b>: <input type='checkbox' id='trade-ridge2' />{'\u00A0'}
<b>C</b>: <input type='checkbox' id='trade-ridge3' />{'\u00A0'} <b>C</b>: <input type='checkbox' id='trade-ridge3' />{'\u00A0'}
<b>T</b>: <input type='checkbox' id='trade-ridge4' />{'\u00A0'} <b>T</b>: <input type='checkbox' id='trade-ridge4' />{'\u00A0'}
<br /><br /> <br /><br />
<Row> <Row>
<Col width='4 column-no-padding'> <Col width='4 column-no-padding'>
<label htmlFor='trade-player'><b>Player</b>:</label> <label htmlFor='trade-player'><b>Player</b>:</label>
<select id='trade-player'> <select id='trade-player'>
{this.props.otherPlayers.map(p => ( {this.props.otherPlayers.map(p => (
<option key={p.player.name} value={p.player.name}>{p.player.name}</option> <option key={p.player.name} value={p.player.name}>{p.player.name}</option>
))} ))}
</select> </select>
</Col> </Col>
<Col width='4 column-no-padding'> <Col width='4 column-no-padding'>
<label htmlFor='trade-money'><b>Money</b>: </label> <label htmlFor='trade-money'><b>Money</b>: </label>
<input type='number' id='trade-money' defaultValue='0' /> <input type='number' id='trade-money' defaultValue='0' />
</Col> </Col>
<Col width='4 column-no-padding'> <Col width='4 column-no-padding'>
<label htmlFor='trade-cards'><b>Cards</b>: </label> <label htmlFor='trade-cards'><b>Cards</b>: </label>
<input type='text' id='trade-cards' /> <input type='text' id='trade-cards' />
</Col> </Col>
</Row> </Row>
<PlayerTradeProposed player={this.props.player} /> <PlayerTradeProposed player={this.props.player} />
<PlayerTradeButton player={this.props.player} /> <PlayerTradeButton player={this.props.player} />
</div> </div>
</form>); </form>);
} }
} }
class PlayerResources extends React.Component { class PlayerResources extends React.Component {
render () { render () {
const player = this.props.player; const player = this.props.player;
return ( return (
<div className='resource-unit-container'> <div className='resource-unit-container'>
<ResourceUnit img={HayImg} h='120' s='100' label='acres of Hay' <ResourceUnit img={HayImg} h='120' s='100' label='acres of Hay'
amount={player.assets.hay}> amount={player.assets.hay}
{player.assets.hay} doubled={player.hayDoubled}
</ResourceUnit> {' '} >
<ResourceUnit img={WheatImg} h='41' s='100' label='acres of Grain' {player.assets.hay}
amount={player.assets.grain}> </ResourceUnit> {' '}
{player.assets.grain} <ResourceUnit img={WheatImg} h='41' s='100' label='acres of Grain'
</ResourceUnit> {' '} amount={player.assets.grain}
<ResourceUnit img={FruitImg} h='0' s='100' label='acres of Fruit' doubled={player.cornDoubled}
amount={player.assets.fruit}> >
{player.assets.fruit} {player.assets.grain}
</ResourceUnit> {' '} </ResourceUnit> {' '}
<ResourceUnit img={CowImg} h='0' s='59' label='head of Cows' <ResourceUnit img={FruitImg} h='0' s='100' label='acres of Fruit'
amount={player.assets.cows}> amount={player.assets.fruit}>
{player.assets.cows} {player.assets.fruit}
</ResourceUnit> {' '} </ResourceUnit> {' '}
<ResourceUnit img={HarvesterImg} h='240' s='100' label='Harvesters' <ResourceUnit img={CowImg} h='0' s='59' label='head of Cows'
amount={player.assets.harvester}> amount={player.assets.cows}>
{player.assets.harvester} {player.assets.cows}
</ResourceUnit> {' '} </ResourceUnit> {' '}
<ResourceUnit img={TractorImg} h='240' s='100' label='Tractors' <ResourceUnit img={HarvesterImg} h='240' s='100' label='Harvesters'
amount={player.assets.tractor}> amount={player.assets.harvester}>
{player.assets.tractor} {player.assets.harvester}
</ResourceUnit> </ResourceUnit> {' '}
<ResourceUnit img={TractorImg} h='240' s='100' label='Tractors'
amount={player.assets.tractor}>
{player.assets.tractor}
</ResourceUnit>
</div> </div>
); );
} }
@ -284,7 +291,7 @@ class PlayerSummary extends React.Component {
const player = this.props.player; const player = this.props.player;
return ( return (
<GroupBox title={(<Fragment><div className={'player player-' + player.color}></div> {player.name} <GroupBox title={(<Fragment><div className={'player player-' + player.color}></div> {player.name}
</Fragment>)}> </Fragment>)}>
<MoneySummary title='Cash' value={player.displayCash} /> {' '} <MoneySummary title='Cash' value={player.displayCash} /> {' '}
<MoneySummary title='Debt' value={player.debt} /> {' '} <MoneySummary title='Debt' value={player.debt} /> {' '}
<br /><br /> <br /><br />
@ -314,13 +321,13 @@ class PlayerTurnContainer extends React.Component {
const player = this.props.player, const player = this.props.player,
worth = netWorth(player), worth = netWorth(player),
auditButton = (this.props.game.calledAudit === false && worth >= this.props.game.settings.auditThreshold) ? ( auditButton = (this.props.game.calledAudit === false && worth >= this.props.game.settings.auditThreshold) ? (
<Button onClick={audit}>Call Audit</Button>) : ''; <Button onClick={audit}>Call Audit</Button>) : '';
if (this.props.game.state === 'finished') { if (this.props.game.state === 'finished') {
view = (<b>Game finished!</b>); view = (<b>Game finished!</b>);
} else if (player.state === GAME_STATES.preTurn) { } else if (player.state === GAME_STATES.preTurn) {
view = ( view = (
<Fragment> <Fragment>
<Button onClick={this.clickRoll}>Roll</Button>{' '}{auditButton} <Button onClick={this.clickRoll}>Roll</Button>{' '}{auditButton}
</Fragment> </Fragment>
); );
} else if (player.state === GAME_STATES.midTurn) { } else if (player.state === GAME_STATES.midTurn) {
@ -330,38 +337,38 @@ class PlayerTurnContainer extends React.Component {
} else { } else {
view = ( view = (
<Button onClick={() => this.props.showScreen(SCREENS.action)}> <Button onClick={() => this.props.showScreen(SCREENS.action)}>
Complete your turn Complete your turn
</Button>); </Button>);
} }
} else { } else {
if (player.cash < 0) { if (player.cash < 0) {
view = ( view = (
<Button onClick={() => this.props.showScreen(SCREENS.loans)}> <Button onClick={() => this.props.showScreen(SCREENS.loans)}>
Raise Cash Raise Cash
</Button> </Button>
); );
} else { } else {
view = ( view = (
<Fragment> <Fragment>
<Button onClick={endTurn}> <Button onClick={endTurn}>
End Turn End Turn
</Button>{' '}{auditButton} </Button>{' '}{auditButton}
</Fragment>); </Fragment>);
} }
} }
} else { } else {
view = ( view = (
<Button onClick={() => this.props.showScreen(SCREENS.action)}> <Button onClick={() => this.props.showScreen(SCREENS.action)}>
Watch {this.props.game.currentPlayer}&apos;s turn Watch {this.props.game.currentPlayer}&apos;s turn
</Button>); </Button>);
} }
return ( return (
<Row> <Row>
<Col width='12'> <Col width='12'>
<div className='turn-container'> <div className='turn-container'>
{view} {view}
</div> </div>
</Col> </Col>
</Row> </Row>
); );
} }
@ -408,10 +415,10 @@ class FarmsContainer extends React.Component {
<b>{ridgeNames[3][0]}</b>: <PlayerColorIcon color={ridges.ridge4} />{'\u00A0'} <b>{ridgeNames[3][0]}</b>: <PlayerColorIcon color={ridges.ridge4} />{'\u00A0'}
<br /><br /> <br /><br />
{this.props.otherPlayers {this.props.otherPlayers
.map(p => ( .map(p => (
<div key={p.player.name}> <div key={p.player.name}>
<PlayerColorIcon color={p.player.color} />{'\u00A0'} <PlayerColorIcon color={p.player.color} />{'\u00A0'}
<b>{p.player.name}</b> <PlayerResources player={p.player} /> <b>{p.player.name}</b> <PlayerResources player={p.player} />
<br /> <br /> <br /> <br />
</div>))} </div>))}
</GroupBox> </GroupBox>
@ -434,7 +441,7 @@ class CCBY extends React.Component {
render() { render() {
return ( return (
<Fragment> <Fragment>
License Creative Commons <a href='https://creativecommons.org/licenses/by/3.0/us/legalcode'>CCBY</a> License Creative Commons <a href='https://creativecommons.org/licenses/by/3.0/us/legalcode'>CCBY</a>
</Fragment> </Fragment>
); );
} }
@ -444,33 +451,33 @@ class Misc extends React.Component {
render() { render() {
return ( return (
<div className='credits'> <div className='credits'>
<h1>Credits</h1> <h1>Credits</h1>
<ul> <ul>
<li> <li>
Game created by <a href='https://thomashintz.org'>Thomas Hintz</a>. Game created by <a href='https://thomashintz.org'>Thomas Hintz</a>.
</li> </li>
<li> <li>
<a href='https://code.thintz.com/farm'>Game source</a> available under the <a href='https://www.gnu.org/licenses/gpl-3.0-standalone.html'>GPLv3</a>+ license. <a href='https://code.thintz.com/farm'>Game source</a> available under the <a href='https://www.gnu.org/licenses/gpl-3.0-standalone.html'>GPLv3</a>+ license.
</li> </li>
<li> <li>
<img src={TractorFullImg} /> <img src={TractorImg} /> Copyright Nick Roach with modifications by Thomas Hintz - License <a href='GPL http://www.gnu.org/copyleft/gpl.html'>GPL</a> <img src={TractorFullImg} /> <img src={TractorImg} /> Copyright Nick Roach with modifications by Thomas Hintz - License <a href='GPL http://www.gnu.org/copyleft/gpl.html'>GPL</a>
</li> </li>
<li> <li>
<img src={CornImg} /> <img src={FruitImg} /> Copyright <a href='https://madexmade.com/'>Made</a> - <CCBY /> <img src={CornImg} /> <img src={FruitImg} /> Copyright <a href='https://madexmade.com/'>Made</a> - <CCBY />
</li> </li>
<li> <li>
<img src={CowImg} /> Copyright <a href='https://thenounproject.com/rivercon/'>rivercon</a> - <CCBY /> <img src={CowImg} /> Copyright <a href='https://thenounproject.com/rivercon/'>rivercon</a> - <CCBY />
</li> </li>
<li> <li>
<img src={HayImg} /> Copyright <a href='https://thenounproject.com/maxicons/'>Maxicons</a> - <CCBY /> <img src={HayImg} /> Copyright <a href='https://thenounproject.com/maxicons/'>Maxicons</a> - <CCBY />
</li> </li>
<li> <li>
<img src={WheatImg} /> Copyright <a href='https://thenounproject.com/amoghdesign/'>P Thanga Vignesh</a> - <CCBY /> <img src={WheatImg} /> Copyright <a href='https://thenounproject.com/amoghdesign/'>P Thanga Vignesh</a> - <CCBY />
</li> </li>
<li> <li>
<img src={HarvesterImg} /> Copyright <a href='https://andrejskirma.com/'>Andrejs Kirma</a> - <CCBY /> <img src={HarvesterImg} /> Copyright <a href='https://andrejskirma.com/'>Andrejs Kirma</a> - <CCBY />
</li> </li>
</ul> </ul>
</div> </div>
); );
} }
@ -482,24 +489,24 @@ class Messages extends React.Component {
newTurn = false; newTurn = false;
return ( return (
<div className='messages'> <div className='messages'>
{this.props.game.messages.map((m, i) => ( {this.props.game.messages.map((m, i) => (
<span key={i}>{m[0] === this.props.player.name ? (<b>{m[0]}</b>) : m[0]}{': ' + m[2]}<br /></span> <span key={i}>{m[0] === this.props.player.name ? (<b>{m[0]}</b>) : m[0]}{': ' + m[2]}<br /></span>
))} ))}
{this.props.game.messages.length > 0 ? (<Fragment><br /><br /></Fragment>) : (<Fragment />)} {this.props.game.messages.length > 0 ? (<Fragment><br /><br /></Fragment>) : (<Fragment />)}
{this.props.game.oldMessages.map((m, i) => { {this.props.game.oldMessages.map((m, i) => {
newTurn = false; newTurn = false;
if (m[1] !== lastTurn) { if (m[1] !== lastTurn) {
lastTurn = m[1]; lastTurn = m[1];
newTurn = true; newTurn = true;
} }
return ( return (
<Fragment key={i}> <Fragment key={i}>
{newTurn ? (<Fragment><b>Turn {m[1]}</b><br /></Fragment>) : <Fragment />} {newTurn ? (<Fragment><b>Turn {m[1]}</b><br /></Fragment>) : <Fragment />}
<span> <span>
{m[0] + ': ' + m[2]} {m[0] + ': ' + m[2]}
<br /></span> <br /></span>
</Fragment> </Fragment>
)})} )})}
</div> </div>
); );
} }
@ -555,6 +562,21 @@ class Loans extends React.Component {
loan(1); loan(1);
} }
maxRepay = e => {
e.preventDefault();
this.setState({ repay: Math.max(0, Math.floor(
Math.min(this.props.player.debt + 900, this.props.player.displayCash) / 1000)) });
}
maxTakeout = e => {
e.preventDefault();
this.setState({ takeOut: Math.max(0, Math.floor(this.state.maxLoan / 1000)) });
}
quickLoan = i => {
loan(i);
}
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.player.debt !== prevProps.player.debt || if (this.props.player.debt !== prevProps.player.debt ||
this.props.game.settings.loanInterest !== prevProps.game.settings.loanInterest || this.props.game.settings.loanInterest !== prevProps.game.settings.loanInterest ||
@ -578,7 +600,12 @@ class Loans extends React.Component {
<br /> <br />
<form onSubmit={this.handleSubmit}> <form onSubmit={this.handleSubmit}>
<Row collapse='true'> <Row collapse='true'>
<Col width='8'> <Col width="2">
{this.props.player.displayCash >= 1000 ? (
<Button className="tiny" onClick={() => this.quickLoan(-1)}>-1</Button>
) : (<span>{' '}</span>)}
</Col>
<Col width='6'>
<div className='money'> <div className='money'>
$: $:
<input onChange={this.handleInput} name='repay' type='number' <input onChange={this.handleInput} name='repay' type='number'
@ -587,11 +614,17 @@ class Loans extends React.Component {
</div> </div>
</Col> </Col>
<Col width='4'> <Col width='4'>
<Button className='tiny' onClick={this.maxRepay}><FontAwesomeIcon icon={faArrowUp} /></Button>{' '}
<Button className='tiny' type='submit'>Repay</Button> <Button className='tiny' type='submit'>Repay</Button>
</Col> </Col>
</Row> </Row>
<Row collapse='true'> <Row collapse='true'>
<Col width='8'> <Col width="2">
{this.props.player.debt < this.props.game.settings.maxDebt ? (
<Button className="tiny" onClick={() => this.quickLoan(1)}>+1</Button>
) : (<span>{' ' }</span>)}
</Col>
<Col width='6'>
<div className='money'> <div className='money'>
$: $:
<input onChange={this.handleInput} name='takeOut' type='number' <input onChange={this.handleInput} name='takeOut' type='number'
@ -600,6 +633,7 @@ class Loans extends React.Component {
</div> </div>
</Col> </Col>
<Col width='4'> <Col width='4'>
<Button className='tiny' onClick={this.maxTakeout}><FontAwesomeIcon icon={faArrowUp} /></Button>{' '}
<Button className='tiny' type='submit'>Take Out</Button> <Button className='tiny' type='submit'>Take Out</Button>
</Col> </Col>
</Row> </Row>
@ -863,19 +897,22 @@ class Harvest extends React.Component {
case 'ready': case 'ready':
view = ( view = (
<div className='clear-background'> <div className='clear-background'>
<div className={'harvest-card space-type-' + this.props.crop}> <div className={'harvest-card space-type-' + this.props.crop}>
<h1>{this.props.crop + ' harvest!'}</h1> <h1>{this.props.crop + ' harvest!'}</h1>
<div className='harvest-card-contents'> <div className='harvest-card-contents'>
<img src={this.cropToImg(this.props.crop)} /> <img src={this.cropToImg(this.props.crop)} />
Get ready to harvest <b>{this.props.acres} Get ready to harvest <b>{this.props.acres}
{this.props.crop === 'cows' ? ' head of cow' : ' acres'}</b>! {this.props.crop === 'cows' ? ' head of cow' : ' acres'}</b>!
</div>
{isCurrentPlayer ? (
<Button onClick={() => this.nextView('roll')}>
Roll for harvest!
</Button>
) : (<Fragment />)}
{this.props.harvestMult !== 1 ? (
<span>Multiplied by {this.props.harvestMult}!</span>
) : (<></>)}
</div> </div>
{isCurrentPlayer ? (
<Button onClick={() => this.nextView('roll')}>
Roll for harvest!
</Button>
) : (<Fragment />)}
</div>
</div> </div>
); );
break; break;
@ -1170,6 +1207,8 @@ class Action extends React.Component {
case 'harvest': case 'harvest':
view = (<Harvest rolled={this.props.ui.actionValue.rolled} view = (<Harvest rolled={this.props.ui.actionValue.rolled}
player={this.props.player} player={this.props.player}
currentPlayer={currentPlayer}
harvestMult={this.props.ui.actionValue.harvestMult}
game={this.props.game} game={this.props.game}
income={this.props.ui.actionValue.income} income={this.props.ui.actionValue.income}
contents={this.props.ui.actionValue.operatingExpense} contents={this.props.ui.actionValue.operatingExpense}
@ -1764,6 +1803,7 @@ class Card extends React.Component {
handleSubmit = e => { handleSubmit = e => {
e.preventDefault(); e.preventDefault();
buy(this.props.card.id, this.state.cash); buy(this.props.card.id, this.state.cash);
this.setState({ cash: 0 });
} }
render () { render () {

@ -92,6 +92,8 @@ const initialState = {
name: '', name: '',
ridges: { ridge1: 0, ridge2: 0, ridge3: 0, ridge4: 0 }, ridges: { ridge1: 0, ridge2: 0, ridge3: 0, ridge4: 0 },
space: 0, space: 0,
hayDoubled: false,
cornDoubled: false,
trade: {} trade: {}
}, },
game: { calledAudit: false, game: { calledAudit: false,

@ -93,7 +93,9 @@
(last-cash initform: 5000 accessor: player-last-cash) (last-cash initform: 5000 accessor: player-last-cash)
(mailbox initform: (make-mailbox) accessor: player-mailbox) (mailbox initform: (make-mailbox) accessor: player-mailbox)
(mutex initform: (make-mutex 'player) accessor: player-mutex) (mutex initform: (make-mutex 'player) accessor: player-mutex)
(harvesting initform: #f accessor: player-harvesting))) (harvesting initform: #f accessor: player-harvesting)
(hay-doubled initform: #f accessor: player-hay-doubled)
(corn-doubled initform: #f accessor: player-corn-doubled)))
(define-class <game> () (define-class <game> ()
((id initform: 0 accessor: game-id) ((id initform: 0 accessor: game-id)
@ -341,7 +343,9 @@
(color . ,(symbol->string (player-color p))) (color . ,(symbol->string (player-color p)))
(name . ,(player-name p)) (name . ,(player-name p))
(trade . ,(player-trade p)) (trade . ,(player-trade p))
(lastCash . ,(player-last-cash p)))))) (lastCash . ,(player-last-cash p))
(hayDoubled . ,(player-hay-doubled p))
(cornDoubled . ,(player-corn-doubled p))))))
(define (game->list g player) (define (game->list g player)
`((game . ((messages . ,(list->vector (reverse (game-messages g)))) `((game . ((messages . ,(list->vector (reverse (game-messages g))))
@ -430,6 +434,8 @@
(safe-set! (player-finished player) #t)))))))) (safe-set! (player-finished player) #t))))))))
(safe-set! (player-year-rules player) (player-next-year-rules player)) (safe-set! (player-year-rules player) (player-next-year-rules player))
(safe-set! (player-next-year-rules player) '()) (safe-set! (player-next-year-rules player) '())
(safe-set! (player-hay-doubled player) #f)
(safe-set! (player-corn-doubled player) #f)
(when (not (null? (player-farmers-fates player))) (when (not (null? (player-farmers-fates player)))
(safe-set! (game-farmers-fates game) (safe-set! (game-farmers-fates game)
(append (game-farmers-fates game) (player-farmers-fates player))) (append (game-farmers-fates game) (player-farmers-fates player)))
@ -1588,6 +1594,8 @@
(when (not (already-harvested? 'wheat player)) (when (not (already-harvested? 'wheat player))
((make-player-pays-per-unit 'grain 50) player))) ((make-player-pays-per-unit 'grain 50) player)))
(define (get-actions player space) (define (get-actions player space)
(let ((res '())) (let ((res '()))
(let loop ((a (let loop ((a
@ -1597,6 +1605,7 @@
((jan2 draw ?p otb)) ((jan2 draw ?p otb))
((jan3 money ?p ,(pays 500)) (?p cows)) ((jan3 money ?p ,(pays 500)) (?p cows))
((jan4 add-rule ?p ,(make-player-year-rule 9 '((?p hay harvest-mult 2) (?p hay))))) ((jan4 add-rule ?p ,(make-player-year-rule 9 '((?p hay harvest-mult 2) (?p hay)))))
((jan4 player-action ?p ,(lambda (p) (safe-set! (player-hay-doubled p) #t))))
((feb1 money ?p ,(gains 1000))) ((feb1 money ?p ,(gains 1000)))
((feb2 draw ?p farmers-fate)) ((feb2 draw ?p farmers-fate))
((feb3 goto ?p apr2)) ((feb3 goto ?p apr2))
@ -1608,6 +1617,7 @@
((apr1 draw ?p otb)) ((apr1 draw ?p otb))
((apr2 add-rule ?p ,(make-player-year-rule ((apr2 add-rule ?p ,(make-player-year-rule
10 '((?p corn harvest-mult 2) (?p grain))))) 10 '((?p corn harvest-mult 2) (?p grain)))))
((apr2 player-action ?p ,(lambda (p) (safe-set! (player-corn-doubled p) #t))))
((apr3 money ?p ,(pays 500))) ((apr3 money ?p ,(pays 500)))
((apr4 money ?p ,(pays 1000))) ((apr4 money ?p ,(pays 1000)))
((may1 money ?p ,(gains 500))) ((may1 money ?p ,(gains 500)))
@ -1790,6 +1800,7 @@
(acres (alist-ref crop (player-assets player))) (acres (alist-ref crop (player-assets player)))
(harvest-amounts (get-harvest-amounts crop)) (harvest-amounts (get-harvest-amounts crop))
(rolled (+ (random 6) 1)) (rolled (+ (random 6) 1))
(harvest-mult (player-harvest-mult player))
(income (income
(farming-round (farming-round
;; add one to skip the divisor ;; add one to skip the divisor
@ -1813,6 +1824,7 @@
((alist-ref 'action operating-expense) player) ((alist-ref 'action operating-expense) player)
`((rolled . ,rolled) `((rolled . ,rolled)
(income . ,income) (income . ,income)
(harvestMult . ,harvest-mult)
(operatingExpense . ,(alist-ref 'contents operating-expense)) (operatingExpense . ,(alist-ref 'contents operating-expense))
(operatingExpenseValue . ((,(string->symbol (player-name player)) (operatingExpenseValue . ((,(string->symbol (player-name player))
. ,(- (player-cash player) . ,(- (player-cash player)
@ -1904,5 +1916,4 @@
;; trade notification keeps popping up ;; trade notification keeps popping up
;; you can see how much money you make before you harvest
;; show harvest multiplier ;; show harvest multiplier

Loading…
Cancel
Save