From 2c80fc4c7b72df0d884e9a33fefe7abd761b1bb9 Mon Sep 17 00:00:00 2001 From: kercylan <61743331+kercylan98@users.noreply.github.com> Date: Fri, 23 Jun 2023 12:54:01 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=A2=9E=E5=8A=A0=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8B=A5=E6=9C=89=E6=89=8B=E7=89=8C=E7=9A=84=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=8E=A9=E5=AE=B6ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/builtin/poker.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/game/builtin/poker.go b/game/builtin/poker.go index c264b46..1e91eef 100644 --- a/game/builtin/poker.go +++ b/game/builtin/poker.go @@ -1,6 +1,9 @@ package builtin -import "github.com/kercylan98/minotaur/utils/maths" +import ( + "github.com/kercylan98/minotaur/utils/hash" + "github.com/kercylan98/minotaur/utils/maths" +) func NewPoker[PlayerID comparable](pile *PokerCardPile, options ...PokerOption[PlayerID]) *Poker[PlayerID] { poker := &Poker[PlayerID]{ @@ -20,18 +23,23 @@ type Poker[PlayerID comparable] struct { handCards map[PlayerID][][]PokerCard } +// GetPlayerIds 获取拥有手牌的所有玩家ID +func (slf *Poker[PlayerID]) GetPlayerIds() []PlayerID { + return hash.KeyToSlice(slf.handCards) +} + // HandCard 获取玩家特定索引的手牌组 func (slf *Poker[PlayerID]) HandCard(playerId PlayerID, index int) []PokerCard { return slf.handCards[playerId][index] } -// HandCards 获取玩家所有手牌 +// HandCards 获取玩家所有手牌组 // - 获取结果为多份手牌 func (slf *Poker[PlayerID]) HandCards(playerId PlayerID) [][]PokerCard { return slf.handCards[playerId] } -// HandCardGroupCount 获取玩家共有多少副手牌 +// HandCardGroupCount 获取玩家共有多少个手牌组 func (slf *Poker[PlayerID]) HandCardGroupCount(playerId PlayerID) int { return len(slf.handCards[playerId]) }