✨ 增加获取拥有手牌的所有玩家ID
This commit is contained in:
parent
789abc065a
commit
2c80fc4c7b
|
@ -1,6 +1,9 @@
|
||||||
package builtin
|
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] {
|
func NewPoker[PlayerID comparable](pile *PokerCardPile, options ...PokerOption[PlayerID]) *Poker[PlayerID] {
|
||||||
poker := &Poker[PlayerID]{
|
poker := &Poker[PlayerID]{
|
||||||
|
@ -20,18 +23,23 @@ type Poker[PlayerID comparable] struct {
|
||||||
handCards map[PlayerID][][]PokerCard
|
handCards map[PlayerID][][]PokerCard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPlayerIds 获取拥有手牌的所有玩家ID
|
||||||
|
func (slf *Poker[PlayerID]) GetPlayerIds() []PlayerID {
|
||||||
|
return hash.KeyToSlice(slf.handCards)
|
||||||
|
}
|
||||||
|
|
||||||
// HandCard 获取玩家特定索引的手牌组
|
// HandCard 获取玩家特定索引的手牌组
|
||||||
func (slf *Poker[PlayerID]) HandCard(playerId PlayerID, index int) []PokerCard {
|
func (slf *Poker[PlayerID]) HandCard(playerId PlayerID, index int) []PokerCard {
|
||||||
return slf.handCards[playerId][index]
|
return slf.handCards[playerId][index]
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandCards 获取玩家所有手牌
|
// HandCards 获取玩家所有手牌组
|
||||||
// - 获取结果为多份手牌
|
// - 获取结果为多份手牌
|
||||||
func (slf *Poker[PlayerID]) HandCards(playerId PlayerID) [][]PokerCard {
|
func (slf *Poker[PlayerID]) HandCards(playerId PlayerID) [][]PokerCard {
|
||||||
return slf.handCards[playerId]
|
return slf.handCards[playerId]
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandCardGroupCount 获取玩家共有多少副手牌
|
// HandCardGroupCount 获取玩家共有多少个手牌组
|
||||||
func (slf *Poker[PlayerID]) HandCardGroupCount(playerId PlayerID) int {
|
func (slf *Poker[PlayerID]) HandCardGroupCount(playerId PlayerID) int {
|
||||||
return len(slf.handCards[playerId])
|
return len(slf.handCards[playerId])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue