File tree Expand file tree Collapse file tree
examples/react/modules/turnorder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,7 +68,9 @@ const opts = {
6868 all: true,
6969
7070 // Use this to set actionPlayers to all players
71- // except the current player.
71+ // except the current player. When combined with
72+ // `once: true`, the current player is added back
73+ // to `actionPlayers` once everyone else takes a move.
7274 allOthers: true,
7375};
7476
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ const TurnExample = Game({
3333
3434 moves : {
3535 playMilitia : ( G , ctx ) => {
36- ctx . events . setActionPlayers ( { allOthers : true } ) ;
36+ ctx . events . setActionPlayers ( { once : true , allOthers : true } ) ;
3737
3838 const currentPlayer = ctx . currentPlayer ;
3939 const playersNext = [ ...G . players ] ;
Original file line number Diff line number Diff line change @@ -552,11 +552,8 @@ export function FlowWithPhases({
552552 if ( state . ctx . _actionPlayersOnce ) {
553553 const playerID = action . playerID ;
554554 actionPlayers = actionPlayers . filter ( id => id !== playerID ) ;
555- }
556- if ( state . ctx . _actionPlayersAllOthers ) {
557- const playerID = action . playerID ;
558- actionPlayers = actionPlayers . filter ( id => id !== playerID ) ;
559- if ( actionPlayers . length === 0 ) {
555+
556+ if ( state . ctx . _actionPlayersAllOthers && actionPlayers . length === 0 ) {
560557 actionPlayers = [ state . ctx . currentPlayer ] ;
561558 }
562559 }
Original file line number Diff line number Diff line change @@ -33,9 +33,16 @@ export const Pass = (G, ctx) => {
3333 * @param {object } arg - An array of playerID's or <object> of:
3434 * {
3535 * value: [], // array of playerID's (optional if all is set).
36+ *
3637 * all: true, // set value to all playerID's
38+ *
3739 * allOthers: true, // set value to all except currentPlayer.
38- * once: true, // players have one move.
40+ * // when combined with `once` (below)
41+ * // currentPlayer is added back after
42+ * // everyone has taken their move.
43+ *
44+ * once: true, // players have one move
45+ * // (after which they're pruned from actionPlayers).
3946 * }
4047 */
4148export function SetActionPlayers ( state , arg ) {
Original file line number Diff line number Diff line change @@ -245,6 +245,7 @@ describe('SetActionPlayers', () => {
245245 B : ( G , ctx ) => {
246246 ctx . events . setActionPlayers ( {
247247 value : [ '0' , '1' , '2' ] ,
248+ once : true ,
248249 allOthers : true ,
249250 } ) ;
250251 return G ;
You can’t perform that action at this time.
0 commit comments