feat(game): add getFront and front for DiscardTile

This commit is contained in:
Kieran Kihn
2025-11-16 11:42:05 +08:00
parent f4f2691c04
commit e2372623ba
2 changed files with 20 additions and 0 deletions

View File

@@ -39,6 +39,11 @@ namespace UNO::GAME {
return card;
}
Card CardTile::front() const
{
return cards_.front();
}
bool CardTile::isEmpty() const
{
return cards_.empty();
@@ -63,6 +68,11 @@ namespace UNO::GAME {
this->pushFront(card);
}
Card DiscardPile::getFront()
{
return this->front();
}
Deck::Deck() = default;
void Deck::init()

View File

@@ -48,6 +48,11 @@ namespace UNO::GAME {
*/
Card popBack();
/**
* @return 牌堆中最上方的牌
*/
[[nodiscard]] Card front() const;
/**
* @return 牌堆是否为空
*/
@@ -78,6 +83,11 @@ namespace UNO::GAME {
* 向弃牌堆中添加 @param card 卡牌
*/
void add(Card card);
/**
* @return 牌堆中最上方的牌
*/
Card getFront();
};
/**