refactor(game): encapsulate Player and ClientGameState state management

- Replaced public `Player::handCard` pointer with private `HandCard` member.
- Introduced `draw`, `play`, and `getCards` methods in `Player` and `ClientGameState`.
- Modified `ClientGameState` constructor to accept player name instead of `Player` object.
- Updated tests to reflect new `Player` and `ClientGameState` structure.
This commit is contained in:
Kieran Kihn
2025-11-18 17:15:07 +08:00
parent 23cd94e656
commit e78741bd9d
5 changed files with 118 additions and 12 deletions

View File

@@ -13,11 +13,7 @@
TEST(game_state_test, game_state_test_1)
{
UNO::GAME::HandCard handCard;
UNO::GAME::Player player(std::string("lzh"));
player.handCard = &handCard;
UNO::GAME::ClientGameState clientGameState(UNO::GAME::GameStatus::WAITING_PLAYERS_TO_NEXT_TURN, player);
UNO::GAME::ClientGameState clientGameState(UNO::GAME::GameStatus::WAITING_PLAYERS_TO_NEXT_TURN, std::string("lzh"));
UNO::GAME::ClientPlayerState playerState1("pkq", 100, false);
UNO::GAME::ClientPlayerState playerState2("kpq", 100, false);