I'm trying to create a replica of the card game "Monopoly Deal" in C# Console, for educational purposes. I have a problem with my class design that I'm not sure how to resolve. I have two classes, Game
and Player
. Game
controls the state of the game, and contains a list of Player
objects.
Currently the way it works is that the Game
class controls everything. The Player
is basically a container class: it has all of the cards in the player's collections. The decision-making is done by the Game
class because it can see all the players, and therefore knows which moves are possible.
For example, if Player 1 wanted to steal a card from Player 2, my program would have to first verify that Player 2 has any cards to steal. Player 1 doesn't know that, because it's just a single object in a list of Player
objects. So the Game
class has a method which checks all possible actions that a player could make, asks the player to choose which action they want to make, and then performs that action for them.
My problem: I don't think that this is good OOP class-design. I think that I should be delegating the decision-making to the Player
class, not the Game
class - otherwise my Game
class will become bloated with lots of methods that relate to player actions and decisions, and not the game state itself. I don't know how to achieve this, however.
Possible solutions:
- Create a
GameState
object containing just a limited view of other players' cards, and pass that to thePlayer
object (Seems the easiest way but I guess it's creating redundant data which is a waste of memory.) - Pass a reference to the whole
Game
object to thePlayer
class (I could do - it's not like I'm going to program by ComputerPlayers to cheat - but doesn't feel like good OOP design either) - Give up, and put all of the game logic (including the computer AI) in the
Game
class, and accept thatPlayer
will just be a data container, not a decision maker. - Redesign my classes a different way.
- Something else I've missed?
Is there any obvious solution here? Thank you.
EDIT: I've attempted to trim down excessive detail in the question as it was closed for "Not enough focus". If further revisions are needed, please let me know.