diff --git a/src/game/GameState.cpp b/src/game/GameState.cpp index 3603578..5d2981b 100644 --- a/src/game/GameState.cpp +++ b/src/game/GameState.cpp @@ -146,13 +146,15 @@ namespace UNO::GAME { } } - void ServerGameState::updateStateByDraw() + std::vector ServerGameState::updateStateByDraw() { if (this->drawCount_ == 0) { this->drawCount_ = 1; } - this->currentPlayer_->draw(this->drawCount_, deck_.draw(this->drawCount_)); + auto cards = deck_.draw(this->drawCount_); + this->currentPlayer_->draw(this->drawCount_, cards); this->drawCount_ = 0; this->nextPlayer(); + return cards; } } // namespace UNO::GAME \ No newline at end of file diff --git a/src/game/GameState.h b/src/game/GameState.h index 01ad70b..15aca2c 100644 --- a/src/game/GameState.h +++ b/src/game/GameState.h @@ -193,7 +193,7 @@ namespace UNO::GAME { /** * 由于用户摸牌而改变状态 */ - void virtual updateStateByDraw(); + std::vector virtual updateStateByDraw(); }; template @@ -294,7 +294,7 @@ namespace UNO::GAME { } template - void GameState::updateStateByDraw() + std::vector GameState::updateStateByDraw() { if (this->drawCount_ == 0) { this->drawCount_ = 1; @@ -302,6 +302,7 @@ namespace UNO::GAME { this->currentPlayer_->draw(this->drawCount_, {}); this->drawCount_ = 0; this->nextPlayer(); + return {}; } class ClientGameState final : public GameState { @@ -309,7 +310,7 @@ namespace UNO::GAME { Player player_; public: - ClientGameState(std::string name); + explicit ClientGameState(std::string name); /** * 获得当前手牌 @@ -357,7 +358,7 @@ namespace UNO::GAME { /** * 由于用户摸牌而改变状态 */ - void updateStateByDraw() override; + std::vector updateStateByDraw() override; }; } // namespace UNO::GAME