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 { faUser, faUsers, faTractor, faWindowRestore,
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 SpaceNode from './SpaceNode.jsx'
@ -180,6 +180,9 @@ class ResourceUnit extends React.Component {
borderTop: '3px solid ' + hslString + '%, 55%)'}}>
{this.props.img ? (<img src={this.props.img} />) : (<Fragment />)}
{this.props.children}
{this.props.doubled ? (
<p>x2!</p>
) : (<></>)}
</div>
);
}
@ -239,11 +242,15 @@ class PlayerResources extends React.Component {
return (
<div className='resource-unit-container'>
<ResourceUnit img={HayImg} h='120' s='100' label='acres of Hay'
amount={player.assets.hay}>
amount={player.assets.hay}
doubled={player.hayDoubled}
>
{player.assets.hay}
</ResourceUnit> {' '}
<ResourceUnit img={WheatImg} h='41' s='100' label='acres of Grain'
amount={player.assets.grain}>
amount={player.assets.grain}
doubled={player.cornDoubled}
>
{player.assets.grain}
</ResourceUnit> {' '}
<ResourceUnit img={FruitImg} h='0' s='100' label='acres of Fruit'
@ -555,6 +562,21 @@ class Loans extends React.Component {
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) {
if (this.props.player.debt !== prevProps.player.debt ||
this.props.game.settings.loanInterest !== prevProps.game.settings.loanInterest ||
@ -578,7 +600,12 @@ class Loans extends React.Component {
<br />
<form onSubmit={this.handleSubmit}>
<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'>
$:
<input onChange={this.handleInput} name='repay' type='number'
@ -587,11 +614,17 @@ class Loans extends React.Component {
</div>
</Col>
<Col width='4'>
<Button className='tiny' onClick={this.maxRepay}><FontAwesomeIcon icon={faArrowUp} /></Button>{' '}
<Button className='tiny' type='submit'>Repay</Button>
</Col>
</Row>
<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'>
$:
<input onChange={this.handleInput} name='takeOut' type='number'
@ -600,6 +633,7 @@ class Loans extends React.Component {
</div>
</Col>
<Col width='4'>
<Button className='tiny' onClick={this.maxTakeout}><FontAwesomeIcon icon={faArrowUp} /></Button>{' '}
<Button className='tiny' type='submit'>Take Out</Button>
</Col>
</Row>
@ -875,6 +909,9 @@ class Harvest extends React.Component {
Roll for harvest!
</Button>
) : (<Fragment />)}
{this.props.harvestMult !== 1 ? (
<span>Multiplied by {this.props.harvestMult}!</span>
) : (<></>)}
</div>
</div>
);
@ -1170,6 +1207,8 @@ class Action extends React.Component {
case 'harvest':
view = (<Harvest rolled={this.props.ui.actionValue.rolled}
player={this.props.player}
currentPlayer={currentPlayer}
harvestMult={this.props.ui.actionValue.harvestMult}
game={this.props.game}
income={this.props.ui.actionValue.income}
contents={this.props.ui.actionValue.operatingExpense}
@ -1764,6 +1803,7 @@ class Card extends React.Component {
handleSubmit = e => {
e.preventDefault();
buy(this.props.card.id, this.state.cash);
this.setState({ cash: 0 });
}
render () {

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

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

Loading…
Cancel
Save