Commit Graph

45 Commits

Author SHA1 Message Date
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
03e1d363e2 fix(game): move clear method to public section in CardTile 2025-11-17 21:14:59 +08:00
Kieran Kihn
091e5f33ca refactor(game): make HandCard default-constructible
- Removed the constructor requiring an array of cards.
2025-11-17 21:14:36 +08:00
Kieran Kihn
d5e1d7f03d fix(game): add validation for card existence in GameState::play
- Throw exception if card is not found in player's hand.
- Ensure loop exits correctly after playing the card.
2025-11-17 15:49:45 +08:00
Kieran Kihn
cbb49343bc fix(game): refactor GameState::onDraw logic
- Replaced direct draw and player update logic with `updateStateByDraw`.
- Simplified card drawing implementation with `handCard->draw`.
2025-11-17 15:24:40 +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
f8666b18b1 test(game): update tests to reflect removal of CardColor::WILD and adjust deck drawing logic 2025-11-17 14:40:22 +08:00
Kieran Kihn
6a148a7e57 fix(game): mark getFront method as [[nodiscard]] 2025-11-17 14:39:34 +08:00
Kieran Kihn
0935b33605 style(game): rename Card constructor parameter from value to type 2025-11-17 14:39:16 +08:00
Kieran Kihn
562ddb25b9 fix(game): remove CardColor::WILD and update wild card handling logic 2025-11-17 14:38:58 +08:00
Kieran Kihn
c3a5a3ee5f feat(game): add getDrawCount method to GameState 2025-11-17 14:01:12 +08:00
Kieran Kihn
6003cadc88 fix(game): use std::move for name in ClientPlayerState constructor 2025-11-17 13:58:55 +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
375abeb2bb fix(game): update Player constructor to take std::string by value instead of reference 2025-11-16 22:06:42 +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
d658a38790 test(game): add test cases for Player 2025-11-16 21:29:43 +08:00
Kieran Kihn
5ad5dabcfc chore: updated CMakeList.txt 2025-11-16 20:57:01 +08:00
Kieran Kihn
44120f1393 test(game): add test cases for CardTile 2025-11-16 20:54:01 +08:00
Kieran Kihn
9e6ded8087 fix(game): changed number of cards 2025-11-16 20:53:21 +08:00
Kieran Kihn
7e996931ef fix(game): fixed unused var in CardTile::shuffle and add const for DiscardPile::getFront() 2025-11-16 20:52:40 +08:00
Kieran Kihn
f06fee17cc fix(common): add defination of COMMON::Utils::instance_ 2025-11-16 20:50:42 +08:00
Kieran Kihn
8dbdbb395c feat(game): add PlayerState and GameState 2025-11-16 20:22:19 +08:00
Kieran Kihn
e2a27e4417 refactor(game): renamed handCard_ to handCard in Player 2025-11-16 20:21:35 +08:00
Kieran Kihn
c8c779d711 fix(game): init Deck in construct function by default 2025-11-16 20:18:19 +08:00
Kieran Kihn
dbaf3c9899 chore: updated ide config 2025-11-16 19:54:34 +08:00
Kieran Kihn
49523a0384 fix(game): changed isEmpty of CardTile from protected to public 2025-11-16 19:54:18 +08:00
Kieran Kihn
da0f2160ce feat(game): add canBePlayedOn for Card 2025-11-16 19:52:47 +08:00
Kieran Kihn
1b9ff0b413 feat(game): add Player 2025-11-16 19:52:09 +08:00
Kieran Kihn
efb80c3b40 feat(game): add operator< for Card 2025-11-16 13:23:41 +08:00
Kieran Kihn
c8ff2dfb16 chore: updated ide config 2025-11-16 12:58:24 +08:00
Kieran Kihn
1e49f5ffbb test(game): add test cases for Card 2025-11-16 11:47:26 +08:00
Kieran Kihn
acd0cae705 chore: updated CMakeList.txt 2025-11-16 11:44:33 +08:00
Kieran Kihn
8873c76904 chore: edited .clang-format 2025-11-16 11:42:48 +08:00
Kieran Kihn
e2372623ba feat(game): add getFront and front for DiscardTile 2025-11-16 11:42:05 +08:00
Kieran Kihn
f4f2691c04 chore: renamed utils to Utils 2025-11-16 11:32:08 +08:00
Kieran Kihn
f28af1978d feat(game): add CardTile 2025-11-15 23:08:11 +08:00
Kieran Kihn
60a058c930 feat(common): add utils::random 2025-11-15 22:27:51 +08:00
Kieran Kihn
543137ed06 feat(game): add new class: Card 2025-11-15 22:22:02 +08:00
Kieran Kihn
9ebf366637 initial commit 2025-11-14 17:43:58 +08:00