diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx
index 81884e0..c3d79f0 100644
--- a/src/components/farm/Board.jsx
+++ b/src/components/farm/Board.jsx
@@ -1352,7 +1352,10 @@ class BoardApp extends React.Component {
-
+
@@ -1383,25 +1386,55 @@ export default connect(
)(BoardApp)
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 () {
const card = this.props.ui.card;
let action = (null);
switch (card.type) {
case 'otb': action = (