|
|
@ -1352,7 +1352,10 @@ class BoardApp extends React.Component {
|
|
|
|
<CardList ui={this.props.ui} />
|
|
|
|
<CardList ui={this.props.ui} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='cell medium-auto'>
|
|
|
|
<div className='cell medium-auto'>
|
|
|
|
<Card ui={this.props.ui} />
|
|
|
|
<Card ui={this.props.ui}
|
|
|
|
|
|
|
|
min={(this.props.ui.card.total * 0.2) / 1000}
|
|
|
|
|
|
|
|
max={Math.floor(Math.min(this.props.player.cash / 1000, this.props.ui.card.total / 1000))}
|
|
|
|
|
|
|
|
cash={(this.props.ui.card.total * 0.2) / 1000} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Row>
|
|
|
|
</Row>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -1383,25 +1386,55 @@ export default connect(
|
|
|
|
)(BoardApp)
|
|
|
|
)(BoardApp)
|
|
|
|
|
|
|
|
|
|
|
|
class Card extends React.Component {
|
|
|
|
class Card extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = { cash: this.props.cash, initialCash: this.props.cash };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static getDerivedStateFromProps(props, state) {
|
|
|
|
|
|
|
|
if (state.initialCash !== props.cash) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
cash: props.cash,
|
|
|
|
|
|
|
|
initialCash: props.cash
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleInput = e => {
|
|
|
|
|
|
|
|
const target = e.target;
|
|
|
|
|
|
|
|
let value = Math.min(Math.max(this.props.min,
|
|
|
|
|
|
|
|
parseInt(target.value)), this.props.max);
|
|
|
|
|
|
|
|
if (isNaN(value)) { value = this.props.min; }
|
|
|
|
|
|
|
|
this.setState({ cash: value });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleSubmit = e => {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
buy(this.props.ui.card.id, this.state.cash);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const card = this.props.ui.card;
|
|
|
|
const card = this.props.ui.card;
|
|
|
|
let action = (null);
|
|
|
|
let action = (null);
|
|
|
|
switch (card.type) {
|
|
|
|
switch (card.type) {
|
|
|
|
case 'otb': action = (
|
|
|
|
case 'otb': action = (
|
|
|
|
<div className='card-action'>
|
|
|
|
<div className='card-action'>
|
|
|
|
<form onSubmit={(e) =>
|
|
|
|
<form onSubmit={this.handleSubmit}>
|
|
|
|
{ e.preventDefault();
|
|
|
|
|
|
|
|
buy(card.id, parseInt(document.getElementById('cash-input').value));
|
|
|
|
|
|
|
|
return false; }}>
|
|
|
|
|
|
|
|
<Row collapse='true'>
|
|
|
|
<Row collapse='true'>
|
|
|
|
<Col width='2'>
|
|
|
|
<Col width='2'>
|
|
|
|
<Button className='tiny' type='submit'>Buy</Button>
|
|
|
|
<Button className='tiny'
|
|
|
|
|
|
|
|
disabled={this.props.max < this.props.min}
|
|
|
|
|
|
|
|
type='submit'>Buy</Button>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|
<Col width='4' />
|
|
|
|
<Col width='4' />
|
|
|
|
<Col width='6'>
|
|
|
|
<Col width='6'>
|
|
|
|
<div className='money'>
|
|
|
|
<div className='money'>
|
|
|
|
$:
|
|
|
|
$:
|
|
|
|
<input id='cash-input' type='number' />
|
|
|
|
<input id='cash-input' type='number'
|
|
|
|
|
|
|
|
disabled={this.props.max < this.props.min}
|
|
|
|
|
|
|
|
onChange={this.handleInput}
|
|
|
|
|
|
|
|
value={this.state.cash} />
|
|
|
|
{'\u00A0'},000
|
|
|
|
{'\u00A0'},000
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Col>
|
|
|
|
</Col>
|
|
|
|