X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=blobdiff_plain;f=tictactoe%2Ftictactoe.jsx;h=d462ae14f164f34b74037d4820f919beaa60d3f1;hp=42c32ef29041345a03d2ca2ddb7ae5cbea5fd2c2;hb=0602929f86c1939b1a52188ecf91096d087f98c7;hpb=2b049fa2c736d7d35beb07a74469e71a56f637ac diff --git a/tictactoe/tictactoe.jsx b/tictactoe/tictactoe.jsx index 42c32ef..d462ae1 100644 --- a/tictactoe/tictactoe.jsx +++ b/tictactoe/tictactoe.jsx @@ -118,7 +118,7 @@ class Game extends React.Component { squares: Array(9).fill(null) } ], - stepNumber: 0, + step_number: 0, next_to_play: Team.X }; } @@ -134,13 +134,13 @@ class Game extends React.Component { squares: Array(9).fill(null) } ], - stepNumber: 0, + step_number: 0, next_to_play: Team.X }); } receiveMove(i) { - const history = this.state.history.slice(0, this.state.stepNumber + 1); + const history = this.state.history.slice(0, this.state.step_number + 1); const current = history[history.length - 1]; const squares = current.squares.slice(); if (calculateWinner(squares) || squares[i]) { @@ -158,7 +158,7 @@ class Game extends React.Component { squares: squares } ]), - stepNumber: history.length, + step_number: history.length, next_to_play: next_to_play }); } @@ -174,16 +174,9 @@ class Game extends React.Component { } } - jumpTo(step) { - this.setState({ - stepNumber: step, - next_to_play: (step % 2) === 0 - }); - } - render() { const history = this.state.history; - const current = history[this.state.stepNumber]; + const current = history[this.state.step_number]; const winner = calculateWinner(current.squares); let status;