diff --git a/src/components/farm/Board.jsx b/src/components/farm/Board.jsx
index 8c1e2fd..156be60 100644
--- a/src/components/farm/Board.jsx
+++ b/src/components/farm/Board.jsx
@@ -51,7 +51,7 @@ import { buy, roll, endTurn, loan, trade, submitTradeAccept,
leaveGame, kickPlayer, toggleRevealForTrade,
addAIPlayer } from './interface.js'
-const showScreenDelay = 2000;
+const showScreenDelay = 0;
function test() {
if (!document.querySelector('.show-for-large .action-item')) {
@@ -79,6 +79,44 @@ function assetsValue(player) {
((player.assets.harvester + player.assets.tractor) * 10000);
}
+class NextActionButton extends React.Component {
+ state = {
+ clicked: false
+ }
+
+ onClick = (e) => {
+ if (this.props.onClick) {
+ this.props.onClick(e);
+ }
+ this.setState({ clicked: true });
+ }
+
+ componentDidUpdate(prevProps) {
+ if (this.state.clicked && this.props.actionId !== this.props.nextActionId) {
+ this.setState({ clicked: false }, () => this.props.showNextAction());
+ }
+ }
+
+ render() {
+ const { clicked } = this.state;
+ if (clicked) {
+ return (
+
+ );
+ } else {
+ const buttonProps = { ...this.props };
+ delete buttonProps['action'];
+ delete buttonProps['nextAction'];
+ delete buttonProps['showNextAction'];
+ delete buttonProps['onClick'];
+ const button = React.cloneElement((
+
+ ), buttonProps);
+ return button;
+ }
+ }
+}
+
class ResourceUnit extends React.Component {
render () {
const hslString = 'hsl(' + this.props.h + ', ' + this.props.s;
@@ -229,7 +267,7 @@ class PlayerTurnContainer extends React.Component {
);
} else if (player.state === GAME_STATES.midTurn) {
- if (this.props.ui.action) {
+ if (this.props.ui.action && this.props.ui.action !== 'actions-end') {
if (this.props.screen === SCREENS.action) {
view = `It's your turn!`;
} else {
@@ -1104,6 +1142,7 @@ class Die extends React.Component {
super(props);
this.state = { num: props.roll ? this.roll() : props.num,
finalFace: false,
+ showScreenTriggered: false,
autoSkip: typeof props.autoSkip === 'undefined' ? false :
props.autoSkip };
this.trigger = 1000 * this.speed[props.speed ? props.speed : 'fast']
@@ -1128,6 +1167,14 @@ class Die extends React.Component {
}
}
+ next = () => {
+ if (this.props.showScreenPlaceholder) {
+ this.setState({ showScreenTriggered: true });
+ } else {
+ this.props.showScreen();
+ }
+ }
+
tick = () => {
let finished = false;
return function() {
@@ -1150,9 +1197,9 @@ class Die extends React.Component {
this.setState({ num: this.props.num, finalFace: true });
if (this.props.showScreen) {
this.showScreenTimerId = setInterval(() => {
- this.props.showScreen();
clearInterval(this.showScreenTimerId);
this.showScreenTimerId = false;
+ this.next();
}, this.props.showScreenDelay);
}
} else {
@@ -1189,9 +1236,9 @@ class Die extends React.Component {
this.setState({ num: this.props.num, finalFace: true });
if (this.props.showScreen) {
this.showScreenTimerId = setInterval(() => {
- this.props.showScreen();
clearInterval(this.showScreenTimerId);
this.showScreenTimerId = false;
+ this.next();
}, this.props.showScreenDelay);
}
}
@@ -1203,6 +1250,8 @@ class Die extends React.Component {
this.skip(true);
}
this.setState({ autoSkip: this.props.autoSkip });
+ } else if (this.state.showScreenTriggered && this.props.showScreenTrigger) {
+ this.props.showScreen();
}
}
@@ -1265,6 +1314,9 @@ class Die extends React.Component {
) :
(
{this.props.ui.actionValue}
); - buttons = (); + buttons = ( +