Skip to content

Commit

Permalink
short form syntax for literal value in setActivePlayers
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolodavis committed Sep 27, 2019
1 parent a9b9b6c commit d43d239
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/turn-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export function SetActivePlayers(ctx, playerID, arg) {

let activePlayers = {};

if (Array.isArray(arg)) {
let value = {};
arg.forEach(v => (value[v] = Stage.NULL));
activePlayers = value;
}

if (arg.value) {
activePlayers = arg.value;
}
Expand Down
11 changes: 11 additions & 0 deletions src/core/turn-order.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ describe('setActivePlayers', () => {
expect(newState.ctx.activePlayers).toMatchObject({ '1': Stage.NULL });
});

test('short form', () => {
const newState = flow.processEvent(
state,
gameEvent('setActivePlayers', [['1', '2']])
);
expect(newState.ctx.activePlayers).toMatchObject({
'1': Stage.NULL,
'2': Stage.NULL,
});
});

test('all', () => {
const newState = flow.processEvent(
state,
Expand Down

0 comments on commit d43d239

Please sign in to comment.