Commit Graph

14 Commits

Author SHA1 Message Date
Kieran Kihn
e78741bd9d 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.
2025-11-18 17:15:07 +08:00
Kieran Kihn
b027e5c4db fix(game): update Card::canBePlayedOn to include draw count validation
- Modified `canBePlayedOn` method to consider `drawCount` for additional play restrictions.
- Updated `GameState::updateStateByCard` to pass `drawCount` when validating playable cards.
2025-11-17 21:33:36 +08:00
Kieran Kihn
ebac6291b0 refactor(game): introduce draw and play methods in PlayerState and subclasses
- Replaced `setRemainingCardCount` with `draw` and `play` methods.
- Added virtual overrides for player-specific behaviors in `ClientPlayerState` and `ServerPlayerState`.
- Refactored `ServerGameState::init` to centralize deck and discard pile setup.
- Updated `updateStateByDraw` to leverage `PlayerState::draw` for consistency.
2025-11-17 21:16:50 +08:00
Kieran Kihn
b8761d1809 fix(game): refactor ServerPlayerState and update ServerGameState::updateStateByCard logic
- Replaced `handCard_` with `handCard` in `ServerPlayerState`.
- Updated `updateStateByCard` in `ServerGameState` to handle card validation and player actions.
- Made `updateStateByCard` virtual in `GameState`.
2025-11-17 15:24:21 +08:00
Kieran Kihn
2c312343d7 fix(game): ensure updateStateByDraw correctly increments player's card count and advances to the next player 2025-11-17 14:55:38 +08:00
Kieran Kihn
c3a5a3ee5f feat(game): add getDrawCount method to GameState 2025-11-17 14:01:12 +08:00
Kieran Kihn
d074feaaa0 fix(game): update updateStateByDraw to correctly adjust player's card count 2025-11-17 13:58:34 +08:00
Kieran Kihn
8ef3962451 refractor(game): simplify nextPlayer logic in GameState 2025-11-17 13:58:13 +08:00
Kieran Kihn
e54bbba4f7 fix(game): update reverse and nextPlayer in GameState to protected 2025-11-17 13:57:30 +08:00
Kieran Kihn
d1fbe5c07a fix(game): preserve currentPlayer index when adding a new player 2025-11-17 12:34:32 +08:00
Kieran Kihn
a025461be8 fix(game): move GameState implementation from .cpp to .h to resolve linkage issues 2025-11-17 12:32:39 +08:00
Kieran Kihn
7740759f33 fix(game): add construct function of ClientGameState 2025-11-16 22:05:36 +08:00
Kieran Kihn
6b2cb78628 fix(game): add setIsUno for PlayerState 2025-11-16 21:47:23 +08:00
Kieran Kihn
8dbdbb395c feat(game): add PlayerState and GameState 2025-11-16 20:22:19 +08:00