From: Carl Worth Date: Thu, 4 Jun 2020 23:19:11 +0000 (-0700) Subject: Rename stepNumber to step_number X-Git-Url: https://git.cworth.org/git?p=lmno.games;a=commitdiff_plain;h=0602929f86c1939b1a52188ecf91096d087f98c7 Rename stepNumber to step_number And drop the dead-code jumpTo while we're at it. I'm gradually rewriting the original tutorial code into my own style. --- 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;