Skip to content

Commit

Permalink
retire flow section
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolodavis committed Sep 10, 2019
1 parent d75fe44 commit 33ac684
Show file tree
Hide file tree
Showing 26 changed files with 241 additions and 322 deletions.
12 changes: 5 additions & 7 deletions examples/react-native/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ const TicTacToe = Game({
},
},

flow: {
turn: { movesPerTurn: 1 },
turn: { movesPerTurn: 1 },

endGameIf: (G, ctx) => {
if (IsVictory(G.cells)) {
return ctx.currentPlayer;
}
},
endGameIf: (G, ctx) => {
if (IsVictory(G.cells)) {
return ctx.currentPlayer;
}
},
});

Expand Down
38 changes: 18 additions & 20 deletions examples/react-web/src/chess/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,27 @@ const ChessGame = Game({
},
},

flow: {
turn: { movesPerTurn: 1 },
turn: { movesPerTurn: 1 },

endGameIf: G => {
const chess = Load(G.pgn);
if (chess.game_over()) {
if (
chess.in_draw() ||
chess.in_threefold_repetition() ||
chess.insufficient_material() ||
chess.in_stalemate()
) {
return 'd';
}
if (chess.in_checkmate()) {
if (chess.turn() == 'w') {
return 'b';
} else {
return 'w';
}
endGameIf: G => {
const chess = Load(G.pgn);
if (chess.game_over()) {
if (
chess.in_draw() ||
chess.in_threefold_repetition() ||
chess.insufficient_material() ||
chess.in_stalemate()
) {
return 'd';
}
if (chess.in_checkmate()) {
if (chess.turn() == 'w') {
return 'b';
} else {
return 'w';
}
}
},
}
},
});

Expand Down
13 changes: 5 additions & 8 deletions examples/react-web/src/phases/diagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import './diagram.css';

const game = Game({
moves: {},

flow: {
startingPhase: 'A',
phases: {
A: { next: 'B' },
B: { next: 'C' },
C: { next: 'A' },
},
startingPhase: 'A',
phases: {
A: { next: 'B' },
B: { next: 'C' },
C: { next: 'A' },
},
});

Expand Down
4 changes: 1 addition & 3 deletions examples/react-web/src/phases/phases.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ const game = Game({
},
},

flow: {
startingPhase: 'take',
},
startingPhase: 'take',
});

class Board extends React.Component {
Expand Down
16 changes: 8 additions & 8 deletions examples/react-web/src/redacted-move/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ const RedactedMoves = Game({
}),

moves: {
/* eslint-disable no-unused-vars */
clickCell(G, ctx, secretstuff) {
return { ...G };
clickCell: {
/* eslint-disable no-unused-vars */
impl: (G, ctx, secretstuff) => {
return { ...G };
},
/* eslint-enable no-unused-vars */
redact: true,
},
/* eslint-enable no-unused-vars */
},

flow: {
redactedMoves: ['clickCell'],
turnOrder: TurnOrder.ANY,
},
turn: { order: TurnOrder.ANY },

playerView: PlayerView.STRIP_SECRETS,
});
Expand Down
18 changes: 8 additions & 10 deletions examples/react-web/src/tic-tac-toe/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ const TicTacToe = Game({
},
},

flow: {
movesPerTurn: 1,
movesPerTurn: 1,

endGameIf: (G, ctx) => {
if (IsVictory(G.cells)) {
return { winner: ctx.currentPlayer };
}
if (G.cells.filter(c => c === null).length == 0) {
return { draw: true };
}
},
endGameIf: (G, ctx) => {
if (IsVictory(G.cells)) {
return { winner: ctx.currentPlayer };
}
if (G.cells.filter(c => c === null).length == 0) {
return { draw: true };
}
},
});

Expand Down
26 changes: 11 additions & 15 deletions examples/react-web/src/turnorder/example-any-once.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import React from 'react';
import { Game, TurnOrder } from 'boardgame.io/core';

const code = `{
flow: {
startingPhase: 'A',
phases: {
A: { turnOrder: TurnOrder.ANY_ONCE, next: 'B' },
B: {},
}
},
startingPhase: 'A',
phases: {
A: { turn: { order: TurnOrder.ANY_ONCE }, next: 'B' },
B: {},
}
}
`;

Expand All @@ -33,15 +31,13 @@ export default {
move: G => G,
},

flow: {
endTurn: false,
endPhase: false,
startingPhase: 'A',
endTurn: false,
endPhase: false,
startingPhase: 'A',

phases: {
A: { turnOrder: TurnOrder.ANY_ONCE, next: 'B' },
B: {},
},
phases: {
A: { turn: { order: TurnOrder.ANY_ONCE }, next: 'B' },
B: {},
},
}),
};
12 changes: 4 additions & 8 deletions examples/react-web/src/turnorder/example-any.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import React from 'react';
import { Game, TurnOrder } from 'boardgame.io/core';

const code = `{
flow: {
turnOrder: TurnOrder.ANY,
},
turn: { order: TurnOrder.ANY },
}
`;

Expand All @@ -29,10 +27,8 @@ export default {
move: G => G,
},

flow: {
endTurn: false,
endPhase: false,
turnOrder: TurnOrder.ANY,
},
endTurn: false,
endPhase: false,
turn: { order: TurnOrder.ANY },
}),
};
10 changes: 3 additions & 7 deletions examples/react-web/src/turnorder/example-custom-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const code = `{
order: ['1', '0', '2', '3', '5', '4'],
}),
flow: {
turnOrder: TurnOrder.CUSTOM_FROM('order'),
},
turn: { order: TurnOrder.CUSTOM_FROM('order') },
}
`;

Expand All @@ -33,9 +31,7 @@ export default {
order: ['1', '0', '2', '3', '5', '4'],
}),

flow: {
endPhase: false,
turnOrder: TurnOrder.CUSTOM_FROM('order'),
},
endPhase: false,
turn: { order: TurnOrder.CUSTOM_FROM('order') },
}),
};
10 changes: 3 additions & 7 deletions examples/react-web/src/turnorder/example-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import React from 'react';
import { Game, TurnOrder } from 'boardgame.io/core';

const code = `{
flow: {
turnOrder: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']),
},
turn: { order: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']) },
}
`;

Expand All @@ -25,9 +23,7 @@ const Description = () => (
export default {
description: Description,
game: Game({
flow: {
endPhase: false,
turnOrder: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']),
},
endPhase: false,
turn: { order: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']) },
}),
};
20 changes: 8 additions & 12 deletions examples/react-web/src/turnorder/example-once.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import React from 'react';
import { Game, TurnOrder } from 'boardgame.io/core';

const code = `{
flow: {
phases: {
A: { turnOrder: TurnOrder.ONCE },
B: {},
},
phases: {
A: { turn: { order: TurnOrder.ONCE }, next: 'B' },
B: {},
},
}
`;
Expand All @@ -28,13 +26,11 @@ const Description = () => (
export default {
description: Description,
game: Game({
flow: {
endPhase: false,
startingPhase: 'A',
phases: {
A: { turnOrder: TurnOrder.ONCE, next: 'B' },
B: {},
},
endPhase: false,
startingPhase: 'A',
phases: {
A: { turn: { order: TurnOrder.ONCE }, next: 'B' },
B: {},
},
}),
};
26 changes: 11 additions & 15 deletions examples/react-web/src/turnorder/example-others-once.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import React from 'react';
import { Game, TurnOrder } from 'boardgame.io/core';

const code = `{
flow: {
startingPhase: 'play',
startingPhase: 'play',
phases: {
play: {},
phases: {
play: {},
discard: {
turnOrder: TurnOrder.OTHERS_ONCE,
},
discard: {
turn: { order: TurnOrder.OTHERS_ONCE },
},
},
Expand All @@ -45,16 +43,14 @@ export default {
description: Description,

game: Game({
flow: {
endPhase: false,
startingPhase: 'play',
endPhase: false,
startingPhase: 'play',

phases: {
play: {},
phases: {
play: {},

discard: {
turnOrder: TurnOrder.OTHERS_ONCE,
},
discard: {
turn: { order: TurnOrder.OTHERS_ONCE },
},
},

Expand Down
10 changes: 3 additions & 7 deletions examples/react-web/src/turnorder/example-others.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import React from 'react';
import { Game, TurnOrder } from 'boardgame.io/core';

const code = `{
flow: {
turnOrder: TurnOrder.OTHERS,
},
turn: { order: TurnOrder.OTHERS },
}
`;

Expand All @@ -29,9 +27,7 @@ export default {
move: G => G,
},

flow: {
endPhase: false,
turnOrder: TurnOrder.OTHERS,
},
endPhase: false,
turn: { order: TurnOrder.OTHERS },
}),
};

0 comments on commit 33ac684

Please sign in to comment.