Improving test routine.

master
Thomas Hintz 5 years ago
parent cb983ae1c9
commit 5609720876

@ -51,14 +51,20 @@ import { buy, roll, endTurn, loan, trade, submitTradeAccept,
leaveGame, kickPlayer, toggleRevealForTrade,
addAIPlayer } from './interface.js'
const showScreenDelay = 0;
let showScreenDelay = 2000;
function test() {
showScreenDelay = 0;
if (!document.querySelector('.show-for-large .action-item')) {
setTimeout(test, 500);
setTimeout(test, 0);
} else {
document.querySelector('.show-for-large .action-item').click();
setTimeout(test, 100);
if (document.querySelector('.show-for-large .action-item')) {
document.querySelector('.show-for-large .action-item').click();
}
if (document.querySelector('.show-for-large .action-item2')) {
document.querySelector('.show-for-large .action-item2').click();
}
setTimeout(test, 0);
}
}
@ -247,11 +253,27 @@ class PlayerSummary extends React.Component {
}
class PlayerTurnContainer extends React.Component {
state = {
endedTurn: false
}
clickRoll = () => {
roll();
this.props.showScreen(SCREENS.action);
}
clickEndTurn = () => {
this.setState({ endedTurn: true });
}
componentDidUpdate(prevProps, prevState) {
if (this.state.endedTurn && !prevState.endedTurn) {
endTurn();
} else if (this.props.player.state === 'pre-turn' && prevProps.player.state !== 'pre-turn') {
this.setState({ endedTurn: false });
}
}
render() {
let view;
const { player, ui } = this.props,
@ -283,10 +305,16 @@ class PlayerTurnContainer extends React.Component {
Raise Cash
</Button>
);
} else if (this.state.endedTurn) {
view = (
<Button disabled={true}>
Loading...
</Button>
);
} else {
view = (
<Fragment>
<Button className="action-item" onClick={endTurn}>
<Button className="action-item" onClick={this.clickEndTurn}>
End Turn
</Button>{' '}{auditButton}
</Fragment>);
@ -1552,7 +1580,8 @@ class Moving extends React.Component {
class Action extends React.Component {
state = {
bertChoice: 'nothing'
bertChoice: 'nothing',
aiPlayerTurnEnded: false
}
setBertChoice = (e) => {
@ -1569,6 +1598,18 @@ class Action extends React.Component {
}
}
endAiTurn = () => {
this.setState({ aiPlayerTurnEnded: true });
}
componentDidUpdate(prevProps, prevState) {
if (this.state.aiPlayerTurnEnded && !prevState.aiPlayerTurnEnded) {
endAiTurn();
} else if (this.props.game.currentPlayer !== prevProps.game.currentPlayer) {
this.setState({ aiPlayerTurnEnded: false });
}
}
render() {
let view,
buttons = false;
@ -1622,14 +1663,18 @@ class Action extends React.Component {
) : (<></>)}
<form onSubmit={this.bertSubmit}>
<label>
<input type="radio" name="bert" value="accept" onClick={this.setBertChoice} />
<input type="radio" name="bert" value="accept" onClick={this.setBertChoice} className="action-item" />
Yes, take over for $10,000!
</label>
<label>
<input type="radio" name="bert" value="deny" onClick={this.setBertChoice} />
No, continue on
</label>
<Button type="submit" disabled={this.state.bertChoice === 'nothing' || this.state.bertChoice === 'accept' && cash < 10000}>Submit</Button>
<Button type="submit" disabled={this.state.bertChoice === 'nothing' || this.state.bertChoice === 'accept' && cash < 10000}
className="action-item2"
>
Submit
</Button>
</form>
</>
);
@ -1777,9 +1822,9 @@ class Action extends React.Component {
screen={this.props.screen}
showScreen={this.props.showScreen}
game={this.props.game} />);
} else if (currentPlayer.ai) {
} else if (currentPlayer.ai && !this.state.aiPlayerTurnEnded) {
view = (
<Button className="action-item" onClick={endAiTurn}>
<Button className="action-item" onClick={this.endAiTurn}>
Next Player's Turn
</Button>
);

Loading…
Cancel
Save