From 61eb8d85bfae395035861939a7ef41202ac8d63b Mon Sep 17 00:00:00 2001 From: Nicolo Davis Date: Wed, 5 Jun 2019 13:24:36 +0800 Subject: [PATCH] rename movesPerTurn to moveLimit --- examples/react-native/game.js | 2 +- examples/react-web/src/chess/game.js | 2 +- examples/react-web/src/tic-tac-toe/game.js | 2 +- examples/react-web/src/ui/chess3d/game.js | 2 +- integration/src/game.js | 2 +- src/ai/bot.test.js | 2 +- src/core/flow.js | 11 ++++------- src/core/flow.test.js | 8 ++++---- 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/examples/react-native/game.js b/examples/react-native/game.js index c0f4bb5e9..5dc0a4fd2 100644 --- a/examples/react-native/game.js +++ b/examples/react-native/game.js @@ -52,7 +52,7 @@ const TicTacToe = { }, }, - turn: { movesPerTurn: 1 }, + turn: { moveLimit: 1 }, endIf: (G, ctx) => { if (IsVictory(G.cells)) { diff --git a/examples/react-web/src/chess/game.js b/examples/react-web/src/chess/game.js index 416f7c7da..1f8f19221 100644 --- a/examples/react-web/src/chess/game.js +++ b/examples/react-web/src/chess/game.js @@ -40,7 +40,7 @@ const ChessGame = { }, }, - turn: { movesPerTurn: 1 }, + turn: { moveLimit: 1 }, endIf: G => { const chess = Load(G.pgn); diff --git a/examples/react-web/src/tic-tac-toe/game.js b/examples/react-web/src/tic-tac-toe/game.js index 749e14d23..0b36bcc18 100644 --- a/examples/react-web/src/tic-tac-toe/game.js +++ b/examples/react-web/src/tic-tac-toe/game.js @@ -52,7 +52,7 @@ const TicTacToe = { }, turn: { - movesPerTurn: 1, + moveLimit: 1, }, endIf: (G, ctx) => { diff --git a/examples/react-web/src/ui/chess3d/game.js b/examples/react-web/src/ui/chess3d/game.js index 416f7c7da..1f8f19221 100644 --- a/examples/react-web/src/ui/chess3d/game.js +++ b/examples/react-web/src/ui/chess3d/game.js @@ -40,7 +40,7 @@ const ChessGame = { }, }, - turn: { movesPerTurn: 1 }, + turn: { moveLimit: 1 }, endIf: G => { const chess = Load(G.pgn); diff --git a/integration/src/game.js b/integration/src/game.js index 28512b42e..37dc03cc1 100644 --- a/integration/src/game.js +++ b/integration/src/game.js @@ -54,7 +54,7 @@ const TicTacToe = Game({ }, flow: { - movesPerTurn: 1, + moveLimit: 1, endGameIf: (G, ctx) => { if (IsVictory(G.cells)) { diff --git a/src/ai/bot.test.js b/src/ai/bot.test.js index 75ab2157b..7616e1b27 100644 --- a/src/ai/bot.test.js +++ b/src/ai/bot.test.js @@ -54,7 +54,7 @@ const TicTacToe = Game({ }, }, - turn: { movesPerTurn: 1 }, + turn: { moveLimit: 1 }, endIf: (G, ctx) => { if (IsVictory(G.cells)) { diff --git a/src/core/flow.js b/src/core/flow.js index 663eb8f85..81a0f5ee4 100644 --- a/src/core/flow.js +++ b/src/core/flow.js @@ -136,7 +136,7 @@ export function Flow({ * * // End the turn automatically after a certain number * // of moves. - * movesPerTurn: 1, + * moveLimit: 1, * * // Code to run at the end of a move. * onMove: (G, ctx, { type: 'moveName', args: [] }) => G @@ -262,10 +262,7 @@ export function FlowWithPhases({ const conf = phaseMap[ctx.phase]; const currentPlayerMoves = ctx.stats.turn.numMoves[ctx.currentPlayer] || 0; - if ( - conf.turn.movesPerTurn && - currentPlayerMoves >= conf.turn.movesPerTurn - ) { + if (conf.turn.moveLimit && currentPlayerMoves >= conf.turn.moveLimit) { return true; } return conf.turn.endIf(G, ctx); @@ -424,9 +421,9 @@ export function FlowWithPhases({ const conf = phaseMap[ctx.phase]; - // Prevent ending the turn if movesPerTurn haven't been made. + // Prevent ending the turn if moveLimit haven't been made. const currentPlayerMoves = ctx.stats.turn.numMoves[ctx.currentPlayer] || 0; - if (conf.turn.movesPerTurn && currentPlayerMoves < conf.turn.movesPerTurn) { + if (conf.turn.moveLimit && currentPlayerMoves < conf.turn.moveLimit) { return state; } diff --git a/src/core/flow.test.js b/src/core/flow.test.js index 2900e661a..633dbc48a 100644 --- a/src/core/flow.test.js +++ b/src/core/flow.test.js @@ -196,11 +196,11 @@ describe('phases', () => { }); }); -test('movesPerTurn', () => { +test('moveLimit', () => { { const flow = FlowWithPhases({ turn: { - movesPerTurn: 2, + moveLimit: 2, }, }); let state = flow.init({ ctx: flow.ctx(2) }); @@ -215,11 +215,11 @@ test('movesPerTurn', () => { { const flow = FlowWithPhases({ - turn: { movesPerTurn: 2 }, + turn: { moveLimit: 2 }, phases: { B: { turn: { - movesPerTurn: 1, + moveLimit: 1, }, }, },