mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 10:23:16 +08:00
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:
@@ -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;
|
||||
|
||||
/**
|
||||
* 由于用户摸牌而改变状态
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user