Documentation
¶
Overview ¶
Package poker 提供了一组用于处理扑克牌游戏的函数和数据结构。该包旨在简化扑克牌游戏的开发过程,并提供一致的接口和易于使用的功能。
主要特性:
- 扑克牌操作:"poker"包支持处理扑克牌的各种操作,如洗牌、发牌、比较牌面大小等。您可以使用这些操作来模拟和实现各种扑克牌游戏。
- 扑克牌规则:该包提供了一系列函数,用于执行常见的扑克牌规则,如判断是否是同花顺、计算牌面点数等。这些函数旨在提供准确和可靠的规则判断和计算结果。
- 扑克牌算法:"poker"包还提供了一些算法,用于解决扑克牌游戏中的问题,如计算最佳牌型、判断是否存在顺子等。这些算法旨在提供高效和优化的解决方案。
- 简化接口:该包的设计目标之一是提供简化的接口,使扑克牌游戏的开发变得更加直观和易于使用。您可以轻松地创建和操作扑克牌对象,而无需处理繁琐的底层细节。
Index ¶
- type Card
- type CardPile
- func (slf *CardPile) Cards() []Card
- func (slf *CardPile) Count() int
- func (slf *CardPile) IsExclude(point Point, color Color) bool
- func (slf *CardPile) IsExcludeWithCard(card Card) bool
- func (slf *CardPile) IsFree() bool
- func (slf *CardPile) Pull(index int) Card
- func (slf *CardPile) PullBottom() Card
- func (slf *CardPile) PullTop() Card
- func (slf *CardPile) Push(index int, card Card)
- func (slf *CardPile) PushBottom(card Card)
- func (slf *CardPile) PushTop(card Card)
- func (slf *CardPile) Reset()
- func (slf *CardPile) Shuffle()
- type CardPileOption
- type Color
- type HandHandle
- type Option
- type Point
- type Poker
- func (slf *Poker) CardValue(cards ...Card) int
- func (slf *Poker) Compare(cards1 []Card, expression maths.CompareExpression, cards2 []Card) bool
- func (slf *Poker) GetPile() *CardPile
- func (slf *Poker) IsContinuity(cards ...Card) bool
- func (slf *Poker) PokerHand(cards ...Card) (cardType string, hit bool)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct {
// contains filtered or unexported fields
}
Card 扑克牌
func NewCard ¶
NewCard 创建一张扑克牌
- 当 point 为 PointBlackJoker 或 PointRedJoker 时,color 将没有效果
Example ¶
package main import ( "fmt" "github.com/kercylan98/minotaur/game/poker" ) func main() { card := poker.NewCard(poker.PointA, poker.ColorSpade) fmt.Println(card) }
Output: (A Spade)
func (Card) GetPointAndColor ¶
GetPointAndColor 返回扑克牌的点数和花色
type CardPile ¶
type CardPile struct {
// contains filtered or unexported fields
}
CardPile 扑克牌堆
func NewCardPile ¶
func NewCardPile(size int, options ...CardPileOption) *CardPile
NewCardPile 返回一个新的牌堆,其中 size 表示了该牌堆由多少副牌组成
- 在不洗牌的情况下,默认牌堆顶部到底部为从大到小排列
Example ¶
package main import ( "fmt" "github.com/kercylan98/minotaur/game/poker" ) func main() { var pile = poker.NewCardPile(1, poker.WithCardPileExcludeCard(poker.NewCard(poker.PointBlackJoker, poker.ColorNone)), ) fmt.Println(pile.Cards()) }
Output: [(R None) (K Spade) (K Heart) (K Club) (K Diamond) (Q Spade) (Q Heart) (Q Club) (Q Diamond) (J Spade) (J Heart) (J Club) (J Diamond) (10 Spade) (10 Heart) (10 Club) (10 Diamond) (9 Spade) (9 Heart) (9 Club) (9 Diamond) (8 Spade) (8 Heart) (8 Club) (8 Diamond) (7 Spade) (7 Heart) (7 Club) (7 Diamond) (6 Spade) (6 Heart) (6 Club) (6 Diamond) (5 Spade) (5 Heart) (5 Club) (5 Diamond) (4 Spade) (4 Heart) (4 Club) (4 Diamond) (3 Spade) (3 Heart) (3 Club) (3 Diamond) (2 Spade) (2 Heart) (2 Club) (2 Diamond) (A Spade) (A Heart) (A Club) (A Diamond)]
func (*CardPile) IsExcludeWithCard ¶
IsExcludeWithCard 检查特定扑克牌是否被排除在外
type CardPileOption ¶
type CardPileOption func(pile *CardPile)
func WithCardPileExcludeCard ¶
func WithCardPileExcludeCard(cards ...Card) CardPileOption
WithCardPileExcludeCard 通过排除特定扑克牌的方式创建牌堆
func WithCardPileExcludeColor ¶
func WithCardPileExcludeColor(colors ...Color) CardPileOption
WithCardPileExcludeColor 通过排除特定花色的方式创建牌堆
func WithCardPileExcludePoint ¶
func WithCardPileExcludePoint(points ...Point) CardPileOption
WithCardPileExcludePoint 通过排除特定点数的方式创建牌堆
func WithCardPileShuffle ¶
func WithCardPileShuffle(shuffleHandle func(pile []Card) []Card) CardPileOption
WithCardPileShuffle 通过特定的洗牌算法创建牌堆
- 需要保证洗牌后的牌堆剩余扑克数量与之前相同,否则将会引发 panic
type HandHandle ¶
HandHandle 扑克牌型验证函数
type Option ¶
type Option func(poker *Poker)
func WithColorValue ¶
WithColorValue 通过特定的扑克花色牌值创建扑克玩法
func WithHand ¶
func WithHand(pokerHand string, handle HandHandle) Option
WithHand 通过绑定特定牌型的方式创建扑克玩法
func WithPointSort ¶
WithPointSort 通过特定的扑克点数顺序创建扑克玩法
func WithPointValue ¶
WithPointValue 通过特定的扑克点数牌值创建扑克玩法
Click to show internal directories.
Click to hide internal directories.