Skip to content

Commit

Permalink
3rd step: Add draw case into game cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrcel97 committed Aug 22, 2018
1 parent 5695711 commit a491f21
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Game extends React.Component {
}

render() {
const MAX_LEN = 9;
this.history = this.state.history;
this.current = this.history[this.history.length-1];
this.winner = calculateWinner(this.current.squares); // Due Game Component now have the squares state this Component will calculateWinner.
Expand All @@ -46,10 +47,11 @@ class Game extends React.Component {
</li>
);
});

let status;
if (this.winner) {
status = 'Winner: ' + this.winner;
} else if (this.history.length-1 === MAX_LEN) {
status = 'Draw...';
} else {
status = 'Next Player: ' + (this.state.xIsNext ? 'X' : 'O');
}
Expand Down

0 comments on commit a491f21

Please sign in to comment.