I'm thinking about a structure like this.
cardGame: players: - john: hand: - card: id: 1 suit: diamond number: 7 deck: - id: 32 suit: spade number: 3
And then, to draw a card there would be a
drawCard(cardGame, john) that pops the card from the deck and appends it to to
john.hand. And then say, if John were to place the card at the bottom of the deck, there would be a sequence of object manipulations, array deletions, etc.
But looking at this, I see risk of accidentally duplicating a card object or running into deep vs. shallow copy issues... is it better to maintain a "flat" structure that is almost like a normalized database table? Ex:
cardGame: deck: - id: 1 suit: diamond number: 7 heldPlayer: john - id: 32 suit: spade number: 3 heldPlayer: null
And in this case, it would be easy for players to swap cards or remove from hands without making any structural changes, though it may be harder to deal with deck positionality? (This could be a failure of imagination on my part)
Intuitively I'd go with the first structure... but I'm not sure what would be better from a stability perspective.