retrived gameInfo from history

This commit is contained in:
Lei Pan 2020-02-19 14:59:46 -08:00
parent 9ef57e6b96
commit b9b16f73a2
1 changed files with 5 additions and 0 deletions

View File

@ -76,6 +76,11 @@ class LeducHoldemGameView extends React.Component {
return gameInfo; return gameInfo;
} }
}else{ }else{
// check if the game state of next turn is already in game state history
if(turn+1 < this.gameStateHistory[gameInfo.round].length){
gameInfo = deepCopy(this.gameStateHistory[gameInfo.round][gameInfo.turn+1]);
return gameInfo;
}
if(gameInfo.currentPlayer === this.moveHistory[gameInfo.round][gameInfo.turn].playerIdx){ if(gameInfo.currentPlayer === this.moveHistory[gameInfo.round][gameInfo.turn].playerIdx){
gameInfo.latestAction[gameInfo.currentPlayer] = this.moveHistory[gameInfo.round][gameInfo.turn].move; gameInfo.latestAction[gameInfo.currentPlayer] = this.moveHistory[gameInfo.round][gameInfo.turn].move;
switch (gameInfo.latestAction[gameInfo.currentPlayer]) { switch (gameInfo.latestAction[gameInfo.currentPlayer]) {