refactor(game): simplify card play logic

- Replaced iterator-based `play` methods with a single card-based method.
- Streamlined logic in `ServerPlayerState`, `ClientGameState`, and `HandCard`.
This commit is contained in:
Kieran Kihn
2025-12-07 13:57:54 +08:00
parent ea87fca1fd
commit 5196de460a
4 changed files with 38 additions and 38 deletions

View File

@@ -8,7 +8,6 @@
*/
#ifndef UNO_GAME_PLAYER_H
#define UNO_GAME_PLAYER_H
#include <array>
#include <set>
#include <vector>
@@ -22,6 +21,13 @@ namespace UNO::GAME {
private:
std::multiset<Card> cards_;
private:
/**
* 打出一张牌
* @param it 要打出的手牌的迭代器
*/
void play(const std::multiset<Card>::iterator &it);
public:
explicit HandCard();
@@ -45,10 +51,9 @@ namespace UNO::GAME {
/**
* 打出一张牌
* @param it 要打出的手牌的迭代器
* @return 打出的手牌
* @param card 要打出的手牌
*/
Card play(const std::multiset<Card>::iterator &it);
void play(const Card &card);
/**
* @return 手牌是否为空
@@ -92,10 +97,9 @@ namespace UNO::GAME {
/**
* 打出一张牌
* @param it 要打出的手牌的迭代器
* @return 打出的手牌
* @param card 要打出的手牌
*/
Card play(const std::multiset<Card>::iterator &it);
void play(const Card &card);
/**
* @return 手牌是否为空