Skip to content

Commit

Permalink
Do not fabricate playerID for playerView
Browse files Browse the repository at this point in the history
the user can now click on the playerID on the Debug UI to see the
view for that particular player.
  • Loading branch information
darthfiddler committed Jul 31, 2018
1 parent bd8208a commit 84f07c6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
6 changes: 1 addition & 5 deletions src/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ class _ClientImpl {
// Secrets are normally stripped on the server,
// but we also strip them here so that game developers
// can see their effects while prototyping.
let playerID = this.playerID;
if (!this.multiplayer && !playerID) {
playerID = state.ctx.currentPlayer;
}
const G = this.game.playerView(state.G, state.ctx, playerID);
const G = this.game.playerView(state.G, state.ctx, this.playerID);

// Combine into return value.
let ret = { ...state, isActive, G };
Expand Down
16 changes: 3 additions & 13 deletions src/client/react-native.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,9 @@ test('local playerView', () => {
numPlayers: 2,
});

{
const game = Enzyme.mount(<Board />);
const board = game.find('TestBoard').instance();
expect(board.props.G).toEqual({ stripped: '0' });
board.props.events.endTurn();
expect(board.props.G).toEqual({ stripped: '1' });
}

{
const game = Enzyme.mount(<Board playerID="1" />);
const board = game.find('TestBoard').instance();
expect(board.props.G).toEqual({ stripped: '1' });
}
const game = Enzyme.mount(<Board playerID="1" />);
const board = game.find('TestBoard').instance();
expect(board.props.G).toEqual({ stripped: '1' });
});

test('reset Game', () => {
Expand Down
16 changes: 3 additions & 13 deletions src/client/react.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,9 @@ test('local playerView', () => {
numPlayers: 2,
});

{
const game = Enzyme.mount(<Board />);
const board = game.find('TestBoard').instance();
expect(board.props.G).toEqual({ stripped: '0' });
board.props.events.endTurn();
expect(board.props.G).toEqual({ stripped: '1' });
}

{
const game = Enzyme.mount(<Board playerID="1" />);
const board = game.find('TestBoard').instance();
expect(board.props.G).toEqual({ stripped: '1' });
}
const game = Enzyme.mount(<Board playerID="1" />);
const board = game.find('TestBoard').instance();
expect(board.props.G).toEqual({ stripped: '1' });
});

test('reset Game', () => {
Expand Down

0 comments on commit 84f07c6

Please sign in to comment.