Boardgame.io: `ctx.currentPlayer` is string

Created on 15 Sep 2019  路  5Comments  路  Source: boardgameio/boardgame.io

Is there any reason why ctx.currentPlayer is string "0" rather than 0.

Most helpful comment

This is due to legacy reasons when it was once thought convenient to have a string so that it can be replaced by a player name.

However, the player names shouldn't be stored as part of the game state, and they're stored in a separate metadata section now. So, we don't really have a reason to keep playerID's as strings and they should be integers instead.

All 5 comments

This is due to legacy reasons when it was once thought convenient to have a string so that it can be replaced by a player name.

However, the player names shouldn't be stored as part of the game state, and they're stored in a separate metadata section now. So, we don't really have a reason to keep playerID's as strings and they should be integers instead.

@nicolodavis Is there a way for the game & board to access the playerName from lobby for ctx.currentPlayer?

Yes, use the gameMetadata prop as documented here.

@nicolodavis Using Lobby instead of the regular Client I don't have gameMetadata in Board's prop. Is this a bug or am I doing something wrong?
I see pretty much every other field from the docs.

Oh I see this is fixed in #436 but not released yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolodavis picture nicolodavis  路  3Comments

jchadwick picture jchadwick  路  4Comments

yangboz picture yangboz  路  5Comments

iCrashed picture iCrashed  路  4Comments

MichalPP picture MichalPP  路  10Comments