janosimas / dominion

Test code for Dominion board game using boardgame.io framework
MIT License
9 stars 3 forks source link

Immutable objects #13

Open rzulian opened 6 years ago

rzulian commented 6 years ago

Hi Jano, Looking at your Dominion implementation to understand best practices on using boardgame.io. In your utils.js your are doing

let buyCard = (state, ctx, player, card) => {

  if (state.custom_onClickBoard) {
    state = state.custom_onClickBoard(state, ctx, player, card);
  } else if (player.treasure >= card.cost) {
    // if the player has treasure to play
    player.treasure -= card.cost;
    player.buy--;
    player.discard.push(card);
    card.count--;
  }

return state

Are you considering the player changes immutable? Or you don't care? Thanks R

janosimas commented 6 years ago

Hi @rzulian, sorry, I didn't understand the problem. What immutable?

janosimas commented 6 years ago

Just to be clear, I'm doing this project to learn using boardgame.io I'm reviewing and changing codes a lot as I find what the best practices are.

nicolodavis commented 6 years ago

http://boardgame.io/#/immutability