Skip to content

Commit fd34df9

Browse files
delucisnicolodavis
andauthored
fix(plugins): Fix PluginPlayer setup (#543)
* test(plugins): Add test for PluginPlayer with game phases * fix(plugins): Don’t restore player & opponent to G.players if undefined Fixes #530 Co-authored-by: Nicolo John Davis <[email protected]>
1 parent 6a10e59 commit fd34df9

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

src/plugins/plugin-player.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export default {
3333

3434
const players = {
3535
...G.players,
36-
[current]: G.player,
36+
[current]: 'player' in G ? G.player : G.players[current],
3737
};
3838

3939
if (other !== null) {
40-
players[other] = G.opponent;
40+
players[other] = 'opponent' in G ? G.opponent : G.players[other];
4141
}
4242

4343
{

src/plugins/plugin-player.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,32 @@ describe('3 player game', () => {
100100
});
101101
});
102102
});
103+
104+
describe('game with phases', () => {
105+
let client;
106+
107+
beforeAll(() => {
108+
const game = {
109+
playerSetup: id => ({ id }),
110+
plugins: [PluginPlayer],
111+
phases: {
112+
phase: {},
113+
},
114+
};
115+
116+
client = Client({ game });
117+
});
118+
119+
test('includes playerSetup state', () => {
120+
expect(client.getState().G).toEqual({
121+
players: {
122+
0: {
123+
id: '0',
124+
},
125+
1: {
126+
id: '1',
127+
},
128+
},
129+
});
130+
});
131+
});

0 commit comments

Comments
 (0)