courageousillumination / deckr

A Card Game Engine for CMSC 22001
MIT License
6 stars 1 forks source link

Make visibility work with multiple players #24

Closed courageousillumination closed 9 years ago

courageousillumination commented 9 years ago

Right now we can only set the visibility of a card for all players. This is fine in solitaire, but doesn't really work in multiplayer games. We need to make it possible to reveal cards to only a single player or a set of players.

courageousillumination commented 9 years ago

There are two options here:

1) Make get_transitions from a game return a list of tuples each of which specifies which players it applies to.

2) Make get_transitions take a player_id and only return transitions that apply to the player.

I'm more inclined towards the second, but I need to think about it some more.

courageousillumination commented 9 years ago

Here's my current outline of a solution:

1) Change make action to not return a list of state transitions 2) Add a method to the game engine get_and _flush_transitions(player_id) that will return a list of transitions for a specific player 3) In the socket code, after we make an action iterate over the players and get the transitions for each of them and broadcast.

This way we don't need to change the webapp at all and we can support player specific transitions in the future. We'll also expand add_transition to take in an optional player argument (if the player argument is not specified it will apply the transition to all players)

courageousillumination commented 9 years ago

Unittests have been added

courageousillumination commented 9 years ago

See #50