Skip to content

Commit 33ac684

Browse files
committed
retire flow section
1 parent d75fe44 commit 33ac684

26 files changed

Lines changed: 241 additions & 322 deletions

examples/react-native/game.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ const TicTacToe = Game({
5454
},
5555
},
5656

57-
flow: {
58-
turn: { movesPerTurn: 1 },
57+
turn: { movesPerTurn: 1 },
5958

60-
endGameIf: (G, ctx) => {
61-
if (IsVictory(G.cells)) {
62-
return ctx.currentPlayer;
63-
}
64-
},
59+
endGameIf: (G, ctx) => {
60+
if (IsVictory(G.cells)) {
61+
return ctx.currentPlayer;
62+
}
6563
},
6664
});
6765

examples/react-web/src/chess/game.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,27 @@ const ChessGame = Game({
4141
},
4242
},
4343

44-
flow: {
45-
turn: { movesPerTurn: 1 },
44+
turn: { movesPerTurn: 1 },
4645

47-
endGameIf: G => {
48-
const chess = Load(G.pgn);
49-
if (chess.game_over()) {
50-
if (
51-
chess.in_draw() ||
52-
chess.in_threefold_repetition() ||
53-
chess.insufficient_material() ||
54-
chess.in_stalemate()
55-
) {
56-
return 'd';
57-
}
58-
if (chess.in_checkmate()) {
59-
if (chess.turn() == 'w') {
60-
return 'b';
61-
} else {
62-
return 'w';
63-
}
46+
endGameIf: G => {
47+
const chess = Load(G.pgn);
48+
if (chess.game_over()) {
49+
if (
50+
chess.in_draw() ||
51+
chess.in_threefold_repetition() ||
52+
chess.insufficient_material() ||
53+
chess.in_stalemate()
54+
) {
55+
return 'd';
56+
}
57+
if (chess.in_checkmate()) {
58+
if (chess.turn() == 'w') {
59+
return 'b';
60+
} else {
61+
return 'w';
6462
}
6563
}
66-
},
64+
}
6765
},
6866
});
6967

examples/react-web/src/phases/diagram.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ import './diagram.css';
1414

1515
const game = Game({
1616
moves: {},
17-
18-
flow: {
19-
startingPhase: 'A',
20-
phases: {
21-
A: { next: 'B' },
22-
B: { next: 'C' },
23-
C: { next: 'A' },
24-
},
17+
startingPhase: 'A',
18+
phases: {
19+
A: { next: 'B' },
20+
B: { next: 'C' },
21+
C: { next: 'A' },
2522
},
2623
});
2724

examples/react-web/src/phases/phases.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ const game = Game({
3232
},
3333
},
3434

35-
flow: {
36-
startingPhase: 'take',
37-
},
35+
startingPhase: 'take',
3836
});
3937

4038
class Board extends React.Component {

examples/react-web/src/redacted-move/game.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ const RedactedMoves = Game({
2020
}),
2121

2222
moves: {
23-
/* eslint-disable no-unused-vars */
24-
clickCell(G, ctx, secretstuff) {
25-
return { ...G };
23+
clickCell: {
24+
/* eslint-disable no-unused-vars */
25+
impl: (G, ctx, secretstuff) => {
26+
return { ...G };
27+
},
28+
/* eslint-enable no-unused-vars */
29+
redact: true,
2630
},
27-
/* eslint-enable no-unused-vars */
2831
},
2932

30-
flow: {
31-
redactedMoves: ['clickCell'],
32-
turnOrder: TurnOrder.ANY,
33-
},
33+
turn: { order: TurnOrder.ANY },
3434

3535
playerView: PlayerView.STRIP_SECRETS,
3636
});

examples/react-web/src/tic-tac-toe/game.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@ const TicTacToe = Game({
5353
},
5454
},
5555

56-
flow: {
57-
movesPerTurn: 1,
56+
movesPerTurn: 1,
5857

59-
endGameIf: (G, ctx) => {
60-
if (IsVictory(G.cells)) {
61-
return { winner: ctx.currentPlayer };
62-
}
63-
if (G.cells.filter(c => c === null).length == 0) {
64-
return { draw: true };
65-
}
66-
},
58+
endGameIf: (G, ctx) => {
59+
if (IsVictory(G.cells)) {
60+
return { winner: ctx.currentPlayer };
61+
}
62+
if (G.cells.filter(c => c === null).length == 0) {
63+
return { draw: true };
64+
}
6765
},
6866
});
6967

examples/react-web/src/turnorder/example-any-once.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import React from 'react';
1010
import { Game, TurnOrder } from 'boardgame.io/core';
1111

1212
const code = `{
13-
flow: {
14-
startingPhase: 'A',
15-
phases: {
16-
A: { turnOrder: TurnOrder.ANY_ONCE, next: 'B' },
17-
B: {},
18-
}
19-
},
13+
startingPhase: 'A',
14+
phases: {
15+
A: { turn: { order: TurnOrder.ANY_ONCE }, next: 'B' },
16+
B: {},
17+
}
2018
}
2119
`;
2220

@@ -33,15 +31,13 @@ export default {
3331
move: G => G,
3432
},
3533

36-
flow: {
37-
endTurn: false,
38-
endPhase: false,
39-
startingPhase: 'A',
34+
endTurn: false,
35+
endPhase: false,
36+
startingPhase: 'A',
4037

41-
phases: {
42-
A: { turnOrder: TurnOrder.ANY_ONCE, next: 'B' },
43-
B: {},
44-
},
38+
phases: {
39+
A: { turn: { order: TurnOrder.ANY_ONCE }, next: 'B' },
40+
B: {},
4541
},
4642
}),
4743
};

examples/react-web/src/turnorder/example-any.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import React from 'react';
1010
import { Game, TurnOrder } from 'boardgame.io/core';
1111

1212
const code = `{
13-
flow: {
14-
turnOrder: TurnOrder.ANY,
15-
},
13+
turn: { order: TurnOrder.ANY },
1614
}
1715
`;
1816

@@ -29,10 +27,8 @@ export default {
2927
move: G => G,
3028
},
3129

32-
flow: {
33-
endTurn: false,
34-
endPhase: false,
35-
turnOrder: TurnOrder.ANY,
36-
},
30+
endTurn: false,
31+
endPhase: false,
32+
turn: { order: TurnOrder.ANY },
3733
}),
3834
};

examples/react-web/src/turnorder/example-custom-from.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ const code = `{
1414
order: ['1', '0', '2', '3', '5', '4'],
1515
}),
1616
17-
flow: {
18-
turnOrder: TurnOrder.CUSTOM_FROM('order'),
19-
},
17+
turn: { order: TurnOrder.CUSTOM_FROM('order') },
2018
}
2119
`;
2220

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

36-
flow: {
37-
endPhase: false,
38-
turnOrder: TurnOrder.CUSTOM_FROM('order'),
39-
},
34+
endPhase: false,
35+
turn: { order: TurnOrder.CUSTOM_FROM('order') },
4036
}),
4137
};

examples/react-web/src/turnorder/example-custom.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import React from 'react';
1010
import { Game, TurnOrder } from 'boardgame.io/core';
1111

1212
const code = `{
13-
flow: {
14-
turnOrder: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']),
15-
},
13+
turn: { order: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']) },
1614
}
1715
`;
1816

@@ -25,9 +23,7 @@ const Description = () => (
2523
export default {
2624
description: Description,
2725
game: Game({
28-
flow: {
29-
endPhase: false,
30-
turnOrder: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']),
31-
},
26+
endPhase: false,
27+
turn: { order: TurnOrder.CUSTOM(['1', '0', '2', '3', '5', '4']) },
3228
}),
3329
};

0 commit comments

Comments
 (0)