DanielAristidou / deck

MIT License
0 stars 0 forks source link

Keeping track of game cards #1

Open DamonTarlaei opened 6 years ago

DamonTarlaei commented 6 years ago

@DanielAristidou

I think that the current structure of piles and deck might have a slight conceptual flaw that is worth examining.

I think that the structures mean that there is a possibility of losing cards. There is no central structure that knows where all the cards are and would be able to account for every card if needed to. Also, given

self.cards = [FaceCard(face, suit) for suit in Suit for face in Face for n in range(packs_of_cards)]

In the deck, I think that cards ought to keep track of what pack they belong to (these can just be numerically assigned, or similar).

It ought to be possible to, for example

assert(Deck.hasAllCards())

I think this might be mitigated by the Game class? I think that the deck ought to be able to know what cards it ought to have, and know when they are all returned and probably the Game ought to be able to say specifically where a given card is?

Thoughts?

DanielAristidou commented 6 years ago

Thanks for the input @DamonTarlaei

So It's certainly possible to check that the initial deck size compared to current deck size for a hasAllCards() , however I don't believe its necessary to keep track of the cards. In fact the Game can do this - deck should only know the cards it does have and cards it gave away and agnostic once the cards have left the deck - cards can then be passed player to player and into the pile without having to inform the deck - the Game should handle all cards.

we can implement a hasCard(face, suit) on the deck, hand and pile

perhaps we should structure this with Game centralised and implement a queue based system where any action returns an event that is then processed by the game and dispatched to the relevant object.

In this case perhaps we should enforce initialisation of the deck with a game session.

Game >> Deck
Game >> Player >> Hand Game >> Pile