jkomoros / boardgame

An in-progress framework in golang to easily build boardgame Progressive Web Apps
Apache License 2.0
31 stars 4 forks source link

Player roster should show scores per player #327

Closed jkomoros closed 7 years ago

jkomoros commented 7 years ago

(For games where there is a score).

GameDelegate would need a way to fetch that property (might be computed!) and then in some cases it seems that you'd want to clarify the text that shoudl be shown.

Are there labeled score subcomponents?

And of course many games have no score so that shouldn't show up

jkomoros commented 7 years ago
jkomoros commented 7 years ago

One option is to have a special thing, like CurrentPlayerIndex() on delegate that outputs score components:

type ScoreComponent struct {
  Name string
  Value int
}

type ScoreComponents struct {
  Components []ScoreComponent
  OverallScore int
}

delegate.ScoreComponentsForPlayer(state boardgame.State, player boardgame.PlayerIndex) ScoreComponents {
  //...
}

Although it seems odd to have a notion of Scores in the base library, when they aren't semantically used anwyhere except in Server.

jkomoros commented 7 years ago

Another option is to have player-roster embed a boardgame-GAMENAME-player-breakdown element that is passed the State, ExpandedState, and the player index and should render whatever works for them. Or just not implement it if they don't have one. (Although unlike the top-level rendering, where veryone will have their own renderer, it's reasonable to not have a roster renderer so you might want an attribute on the player-roster that says "don't even bother loading a roster for this game"

jkomoros commented 7 years ago
jkomoros commented 7 years ago

Check whether the player-status renderer already is defined (e.g. with customElements.get). It is up to the player-roster itself to fetch the definition, if it exists (we create N player-infos within the roster, and wouldn't want them all to try to define the status thing)