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`.
This commit is contained in:
Kieran Kihn
2025-11-17 15:24:21 +08:00
parent 2c312343d7
commit b8761d1809
2 changed files with 26 additions and 13 deletions

View File

@@ -66,14 +66,10 @@ namespace UNO::GAME {
* (供服务端使用)玩家状态
*/
class ServerPlayerState : public PlayerState {
private:
HandCard *handCard_;
public:
explicit ServerPlayerState(std::string name, size_t remainingCardCount, bool isUno, HandCard *handCard);
template<typename... T>
void draw(T... args);
HandCard *handCard;
};
/**
@@ -156,7 +152,7 @@ namespace UNO::GAME {
* 由于用户出牌而改变状态
* @param card 用户出的牌
*/
void updateStateByCard(const Card &card);
void virtual updateStateByCard(const Card &card);
/**
* 由于用户摸牌而改变状态
@@ -287,6 +283,12 @@ namespace UNO::GAME {
public:
ServerGameState();
/**
* 由于用户出牌而改变状态
* @param card 用户出的牌
*/
void updateStateByCard(const Card &card) override;
/**
* 由于用户摸牌而改变状态
*/