AleksandarDzh / card-game-basics

This is a simple structure of card game basics
0 stars 0 forks source link

Inconsistency: The cards suit is being part of the Deck but the rank is part of the Card class #2

Open pnikolov opened 1 year ago

pnikolov commented 1 year ago

https://github.com/AleksandarDzh/card-game-basics/blob/24e3b571535f60f00630a39b82fa859aa6ce9fd1/CardGame_Basics/src/Deck.php#L13

It seems that a card's rank and its suite is being defined in two different places:

Can you explain what is the idea behind this implementation?

AleksandarDzh commented 1 year ago

Correct. This is the thing I spent the most time on and implemented several times. Originally, the suits were part of the card just like ranks. Something was bugging me, though, and I started to think that maybe the four suits as a whole were more of a property of the deck, and the individual suit was a property of the card. That's why I ended up separating them as part of the deck. However, I didn't like that either and I started thinking about the option where they might be used by both the deck and the card at the same time, and in that line of thinking it might be best to have them as a separate object that unites the cards with the deck, and so I came up with the second solution where the suit is a separate structure.