poker

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package poker 提供了一组用于处理扑克牌游戏的函数和数据结构。该包旨在简化扑克牌游戏的开发过程,并提供一致的接口和易于使用的功能。

主要特性:

  • 扑克牌操作:"poker"包支持处理扑克牌的各种操作,如洗牌、发牌、比较牌面大小等。您可以使用这些操作来模拟和实现各种扑克牌游戏。
  • 扑克牌规则:该包提供了一系列函数,用于执行常见的扑克牌规则,如判断是否是同花顺、计算牌面点数等。这些函数旨在提供准确和可靠的规则判断和计算结果。
  • 扑克牌算法:"poker"包还提供了一些算法,用于解决扑克牌游戏中的问题,如计算最佳牌型、判断是否存在顺子等。这些算法旨在提供高效和优化的解决方案。
  • 简化接口:该包的设计目标之一是提供简化的接口,使扑克牌游戏的开发变得更加直观和易于使用。您可以轻松地创建和操作扑克牌对象,而无需处理繁琐的底层细节。

Index

Examples

Constants

View Source
const (
	HandNone = "None" // 无牌型
)

Variables

This section is empty.

Functions

func GroupByColor added in v0.0.3

func GroupByColor(cards ...Card) map[Color][]Card

GroupByColor 将扑克牌按照花色分组

func GroupByPoint added in v0.0.3

func GroupByPoint(cards ...Card) map[Point][]Card

GroupByPoint 将扑克牌按照点数分组

func IsContainJoker added in v0.0.3

func IsContainJoker(cards ...Card) bool

IsContainJoker 检查扑克牌是否包含大小王

func IsFlush added in v0.0.3

func IsFlush(cards ...Card) bool

IsFlush 判断是否是同花

func IsRocket added in v0.0.3

func IsRocket(cardA, cardB Card) bool

IsRocket 两张牌能否组成红黑 Joker

Types

type Card

type Card struct {
	// contains filtered or unexported fields
}

Card 扑克牌

func NewCard

func NewCard(point Point, color Color) Card

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) CalcColorDifference added in v0.0.3

func (slf Card) CalcColorDifference(card Card) int

CalcColorDifference 计算两张扑克牌的花色差

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.CalcColorDifference(card2))

}
Output:

1

func (Card) CalcColorDifferenceAbs added in v0.0.3

func (slf Card) CalcColorDifferenceAbs(card Card) int

CalcColorDifferenceAbs 计算两张扑克牌的花色差的绝对值

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.CalcColorDifferenceAbs(card2))

}
Output:

1

func (Card) CalcPointDifference added in v0.0.3

func (slf Card) CalcPointDifference(card Card) int

CalcPointDifference 计算两张扑克牌的点数差

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
	fmt.Println(card1.CalcPointDifference(card2))

}
Output:

-1

func (Card) CalcPointDifferenceAbs added in v0.0.3

func (slf Card) CalcPointDifferenceAbs(card Card) int

CalcPointDifferenceAbs 计算两张扑克牌的点数差的绝对值

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
	fmt.Println(card1.CalcPointDifferenceAbs(card2))

}
Output:

1

func (Card) Equal

func (slf Card) Equal(card Card) bool

Equal 比较与另一张扑克牌的点数和花色是否相同

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorSpade)
	fmt.Println(card1.Equal(card2))

}
Output:

true

func (Card) EqualColor

func (slf Card) EqualColor(card Card) bool

EqualColor 比较与另一张扑克牌的花色是否相同

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.EqualColor(card2))

}
Output:

false

func (Card) EqualPoint

func (slf Card) EqualPoint(card Card) bool

EqualPoint 比较与另一张扑克牌的点数是否相同

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.EqualPoint(card2))

}
Output:

true

func (Card) GetColor

func (slf Card) GetColor() Color

GetColor 返回扑克牌的花色

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card := poker.NewCard(poker.PointA, poker.ColorSpade)
	fmt.Println(card.GetColor())

}
Output:

Spade

func (Card) GetPoint

func (slf Card) GetPoint() Point

GetPoint 返回扑克牌的点数

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card := poker.NewCard(poker.PointA, poker.ColorSpade)
	fmt.Println(card.GetPoint())

}
Output:

A

func (Card) GetPointAndColor

func (slf Card) GetPointAndColor() (Point, Color)

GetPointAndColor 返回扑克牌的点数和花色

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card := poker.NewCard(poker.PointA, poker.ColorSpade)
	fmt.Println(card.GetPointAndColor())

}
Output:

A Spade

func (Card) IsJoker added in v0.0.3

func (slf Card) IsJoker() bool

IsJoker 判断是否为大小王

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card := poker.NewCard(poker.PointA, poker.ColorSpade)
	fmt.Println(card.IsJoker())

}
Output:

false

func (Card) IsNeighborColor added in v0.0.3

func (slf Card) IsNeighborColor(card Card) bool

IsNeighborColor 判断两张扑克牌是否为相邻的花色

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.IsNeighborColor(card2))

}
Output:

true

func (Card) IsNeighborPoint added in v0.0.3

func (slf Card) IsNeighborPoint(card Card) bool

IsNeighborPoint 判断两张扑克牌是否为相邻的点数

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
	fmt.Println(card1.IsNeighborPoint(card2))

}
Output:

true

func (Card) Max added in v0.0.3

func (slf Card) Max(card Card) Card

Max 返回两张扑克牌中点数和花色较大的一张

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.Max(card2))

}
Output:

(A Spade)

func (Card) MaxColor added in v0.0.3

func (slf Card) MaxColor(card Card) Card

MaxColor 返回两张扑克牌中花色较大的一张

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.MaxColor(card2))

}
Output:

(A Spade)

func (Card) MaxPoint added in v0.0.3

func (slf Card) MaxPoint(card Card) Card

MaxPoint 返回两张扑克牌中点数较大的一张

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
	fmt.Println(card1.MaxPoint(card2))

}
Output:

(2 Spade)

func (Card) Min added in v0.0.3

func (slf Card) Min(card Card) Card

Min 返回两张扑克牌中点数和花色较小的一张

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.Min(card2))

}
Output:

(A Heart)

func (Card) MinColor added in v0.0.3

func (slf Card) MinColor(card Card) Card

MinColor 返回两张扑克牌中花色较小的一张

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.PointA, poker.ColorHeart)
	fmt.Println(card1.MinColor(card2))

}
Output:

(A Heart)

func (Card) MinPoint added in v0.0.3

func (slf Card) MinPoint(card Card) Card

MinPoint 返回两张扑克牌中点数较小的一张

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card1 := poker.NewCard(poker.PointA, poker.ColorSpade)
	card2 := poker.NewCard(poker.Point2, poker.ColorSpade)
	fmt.Println(card1.MinPoint(card2))

}
Output:

(A Spade)

func (Card) String

func (slf Card) String() string

String 将扑克牌转换为字符串形式

Example
package main

import (
	"fmt"
	"github.com/kercylan98/minotaur/game/poker"
)

func main() {
	card := poker.NewCard(poker.PointA, poker.ColorSpade)
	fmt.Println(card.String())

}
Output:

(A Spade)

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 Diamond) (K Club) (K Heart) (K Spade) (Q Diamond) (Q Club) (Q Heart) (Q Spade) (J Diamond) (J Club) (J Heart) (J Spade) (10 Diamond) (10 Club) (10 Heart) (10 Spade) (9 Diamond) (9 Club) (9 Heart) (9 Spade) (8 Diamond) (8 Club) (8 Heart) (8 Spade) (7 Diamond) (7 Club) (7 Heart) (7 Spade) (6 Diamond) (6 Club) (6 Heart) (6 Spade) (5 Diamond) (5 Club) (5 Heart) (5 Spade) (4 Diamond) (4 Club) (4 Heart) (4 Spade) (3 Diamond) (3 Club) (3 Heart) (3 Spade) (2 Diamond) (2 Club) (2 Heart) (2 Spade) (A Diamond) (A Club) (A Heart) (A Spade)]

func (*CardPile) Cards

func (slf *CardPile) Cards() []Card

Cards 获取当前牌堆的所有扑克牌

func (*CardPile) Count

func (slf *CardPile) Count() int

Count 获取牌堆剩余牌量

func (*CardPile) IsExclude

func (slf *CardPile) IsExclude(point Point, color Color) bool

IsExclude 检查特定点数和花色是否被排除在外

func (*CardPile) IsExcludeWithCard

func (slf *CardPile) IsExcludeWithCard(card Card) bool

IsExcludeWithCard 检查特定扑克牌是否被排除在外

func (*CardPile) IsFree

func (slf *CardPile) IsFree() bool

IsFree 返回牌堆是否没有扑克牌了

func (*CardPile) Pull

func (slf *CardPile) Pull(index int) Card

Pull 从牌堆特定位置抽出一张牌

func (*CardPile) PullBottom

func (slf *CardPile) PullBottom() Card

PullBottom 从牌堆底部抽出一张牌

func (*CardPile) PullTop

func (slf *CardPile) PullTop() Card

PullTop 从牌堆顶部抽出一张牌

func (*CardPile) Push

func (slf *CardPile) Push(index int, card Card)

Push 将扑克牌插入到牌堆特定位置

func (*CardPile) PushBottom

func (slf *CardPile) PushBottom(card Card)

PushBottom 将扑克牌插入到牌堆底部

func (*CardPile) PushTop

func (slf *CardPile) PushTop(card Card)

PushTop 将扑克牌插入到牌堆顶部

func (*CardPile) Reset

func (slf *CardPile) Reset()

Reset 重置牌堆的扑克牌数量及顺序

func (*CardPile) Shuffle

func (slf *CardPile) Shuffle()

Shuffle 洗牌

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 Color

type Color int

Color 扑克牌花色

const (
	ColorNone    Color = 0 // 无花色,通常为大小王
	ColorSpade   Color = 4 // 黑桃
	ColorHeart   Color = 3 // 红桃
	ColorClub    Color = 2 // 梅花
	ColorDiamond Color = 1 // 方片
)

func GetCardsColor

func GetCardsColor(cards ...Card) []Color

GetCardsColor 获取一组扑克牌的花色

func (Color) InBounds

func (slf Color) InBounds() bool

InBounds 扑克牌花色是否在界限内

  • 将检查花色是否在黑桃、红桃、梅花、方片之间

func (Color) String

func (slf Color) String() string

type HandHandle

type HandHandle func(rule *Rule, cards []Card) bool

HandHandle 扑克牌型验证函数

func HandBomb added in v0.0.3

func HandBomb() HandHandle

HandBomb 炸弹

func HandFlush added in v0.0.3

func HandFlush() HandHandle

HandFlush 同花

  • 表示所有牌的花色都相同

func HandFlushStraight added in v0.0.3

func HandFlushStraight(count, lower, limit int) HandHandle

HandFlushStraight 同花顺

  • count: 顺子的对子数量,例如当 count = 2 时,可以是 334455、445566、556677、667788、778899
  • lower: 顺子的最小连续数量
  • limit: 顺子的最大连续数量

func HandFourWithOne added in v0.0.3

func HandFourWithOne() HandHandle

HandFourWithOne 四带一

func HandFourWithThree added in v0.0.3

func HandFourWithThree() HandHandle

HandFourWithThree 四带三

func HandFourWithTwo added in v0.0.3

func HandFourWithTwo() HandHandle

HandFourWithTwo 四带二

func HandFourWithTwoPairs added in v0.0.3

func HandFourWithTwoPairs() HandHandle

HandFourWithTwoPairs 四带两对

func HandLeopard added in v0.0.3

func HandLeopard() HandHandle

HandLeopard 豹子

  • 表示三张点数相同的牌
  • 例如:333、444、555、666、777、888、999、JJJ、QQQ、KKK、AAA
  • 大小王不能用于豹子,因为他们没有点数

func HandOrderFourWithOne added in v0.0.3

func HandOrderFourWithOne(count int) HandHandle

HandOrderFourWithOne 四带一顺子

func HandOrderFourWithThree added in v0.0.3

func HandOrderFourWithThree(count int) HandHandle

HandOrderFourWithThree 四带三顺子

func HandOrderFourWithTwo added in v0.0.3

func HandOrderFourWithTwo(count int) HandHandle

HandOrderFourWithTwo 四带二顺子

func HandOrderPairs added in v0.0.3

func HandOrderPairs(count int) HandHandle

HandOrderPairs 对子顺子

func HandOrderSingle added in v0.0.3

func HandOrderSingle(count int) HandHandle

HandOrderSingle 顺子

func HandOrderSingleFour added in v0.0.3

func HandOrderSingleFour(count int) HandHandle

HandOrderSingleFour 四张顺子

func HandOrderSingleThree added in v0.0.3

func HandOrderSingleThree(count int) HandHandle

HandOrderSingleThree 三张顺子

func HandOrderThreeWithOne added in v0.0.3

func HandOrderThreeWithOne(count int) HandHandle

HandOrderThreeWithOne 三带一顺子

func HandOrderThreeWithTwo added in v0.0.3

func HandOrderThreeWithTwo(count int) HandHandle

HandOrderThreeWithTwo 三带二顺子

func HandPairs

func HandPairs() HandHandle

HandPairs 对子

func HandPlane added in v0.0.3

func HandPlane() HandHandle

HandPlane 飞机

  • 表示三张点数相同的牌组成的连续的牌

func HandPlaneWithOne added in v0.0.3

func HandPlaneWithOne() HandHandle

HandPlaneWithOne 飞机带单

func HandRocket added in v0.0.3

func HandRocket() HandHandle

HandRocket 王炸

  • 表示一对王牌,即大王和小王

func HandSingle

func HandSingle() HandHandle

HandSingle 单牌

func HandStraightPairs added in v0.0.3

func HandStraightPairs() HandHandle

HandStraightPairs 连对

func HandThreeOfKind

func HandThreeOfKind() HandHandle

HandThreeOfKind 三张

func HandThreeOfKindWithOne added in v0.0.3

func HandThreeOfKindWithOne() HandHandle

HandThreeOfKindWithOne 三带一

func HandThreeOfKindWithTwo added in v0.0.3

func HandThreeOfKindWithTwo() HandHandle

HandThreeOfKindWithTwo 三带二

func HandTwoWithOne added in v0.0.3

func HandTwoWithOne() HandHandle

HandTwoWithOne 二带一

  • 表示两张点数相同的牌,加上一张其他点数的牌
  • 例如:334、445、556、667、778、889、99J、TTQ、JJK、QQA、AA2
  • 大小王不能用于二带一,因为他们没有点数
  • 通常用于炸金花玩法中检查对子

type Option

type Option func(rule *Rule)

func WithColorSort added in v0.0.3

func WithColorSort(colorSort map[Color]int) Option

WithColorSort 通过特定的扑克花色顺序创建扑克玩法,顺序必须为连续的

func WithColorValue

func WithColorValue(colorValues map[Color]int) Option

WithColorValue 通过特定的扑克花色牌值创建扑克玩法

func WithExcludeContinuityPoint added in v0.0.3

func WithExcludeContinuityPoint(points ...Point) Option

WithExcludeContinuityPoint 排除连续的点数

func WithHand

func WithHand(pokerHand string, value int, handle HandHandle) Option

WithHand 通过绑定特定牌型的方式创建扑克玩法

  • 牌型顺序决定了牌型的优先级

func WithHandRestraint added in v0.0.3

func WithHandRestraint(pokerHand, restraint string) Option

WithHandRestraint 通过绑定特定克制牌型的方式创建扑克玩法

func WithHandRestraintFull added in v0.0.3

func WithHandRestraintFull(pokerHand string) Option

WithHandRestraintFull 通过绑定所有克制牌型的方式创建扑克玩法

  • 需要确保在牌型声明之后调用

func WithPointSort

func WithPointSort(pointSort map[Point]int) Option

WithPointSort 通过特定的扑克点数顺序创建扑克玩法,顺序必须为连续的

func WithPointValue

func WithPointValue(pointValues map[Point]int) Option

WithPointValue 通过特定的扑克点数牌值创建扑克玩法

type Point

type Point int

Point 扑克点数

const (
	PointA          Point = 1
	Point2          Point = 2
	Point3          Point = 3
	Point4          Point = 4
	Point5          Point = 5
	Point6          Point = 6
	Point7          Point = 7
	Point8          Point = 8
	Point9          Point = 9
	Point10         Point = 10
	PointJ          Point = 11
	PointQ          Point = 12
	PointK          Point = 13
	PointBlackJoker Point = 14
	PointRedJoker   Point = 15
)

func GetCardsPoint

func GetCardsPoint(cards ...Card) []Point

GetCardsPoint 获取一组扑克牌的点数

func (Point) String

func (slf Point) String() string

type Rule added in v0.0.3

type Rule struct {
	// contains filtered or unexported fields
}

func NewRule added in v0.0.3

func NewRule(options ...Option) *Rule

func (*Rule) CompareValueWithCards added in v0.0.3

func (slf *Rule) CompareValueWithCards(cards1 []Card, expression maths.CompareExpression, cards2 []Card) bool

CompareValueWithCards 根据特定的条件表达式比较两组扑克牌的牌值

func (*Rule) GetCardCount added in v0.0.4

func (slf *Rule) GetCardCount(cards []Card, card Card) int

GetCardCount 获取指定牌的数量

func (*Rule) GetCardCountWithColor added in v0.0.4

func (slf *Rule) GetCardCountWithColor(cards []Card, color Color) int

GetCardCountWithColor 获取指定花色的牌的数量

func (*Rule) GetCardCountWithColorMaximumNumber added in v0.0.4

func (slf *Rule) GetCardCountWithColorMaximumNumber(cards []Card, color Color, maximumNumber int) int

GetCardCountWithColorMaximumNumber 获取指定花色的牌的数量

func (*Rule) GetCardCountWithMaximumNumber added in v0.0.4

func (slf *Rule) GetCardCountWithMaximumNumber(cards []Card, card Card, maximumNumber int) int

GetCardCountWithMaximumNumber 获取指定牌的数量

func (*Rule) GetCardCountWithPoint added in v0.0.4

func (slf *Rule) GetCardCountWithPoint(cards []Card, point Point) int

GetCardCountWithPoint 获取指定点数的牌的数量

func (*Rule) GetCardCountWithPointMaximumNumber added in v0.0.4

func (slf *Rule) GetCardCountWithPointMaximumNumber(cards []Card, point Point, maximumNumber int) int

GetCardCountWithPointMaximumNumber 获取指定点数的牌的数量

func (*Rule) GetValueWithCards added in v0.0.3

func (slf *Rule) GetValueWithCards(cards ...Card) int

GetValueWithCards 获取扑克牌的牌值

func (*Rule) GetValueWithColor added in v0.0.3

func (slf *Rule) GetValueWithColor(color Color) int

GetValueWithColor 获取扑克牌的花色牌值

func (*Rule) GetValueWithPoint added in v0.0.3

func (slf *Rule) GetValueWithPoint(point Point) int

GetValueWithPoint 获取扑克牌的点数牌值

func (*Rule) GetValueWithPokerHand added in v0.0.3

func (slf *Rule) GetValueWithPokerHand(hand string, cards ...Card) int

GetValueWithPokerHand 获取扑克牌的牌型牌值

func (*Rule) IsPointContinuity added in v0.0.3

func (slf *Rule) IsPointContinuity(count int, cards ...Card) bool

IsPointContinuity 检查一组扑克牌点数是否连续,count 表示了每个点数的数量

func (*Rule) IsSameColor added in v0.0.3

func (slf *Rule) IsSameColor(cards ...Card) bool

IsSameColor 检查一组扑克牌是否同花

func (*Rule) IsSamePoint added in v0.0.3

func (slf *Rule) IsSamePoint(cards ...Card) bool

IsSamePoint 检查一组扑克牌是否同点

func (*Rule) PokerHand added in v0.0.3

func (slf *Rule) PokerHand(cards ...Card) (pokerHand string, hit bool)

PokerHand 获取一组扑克的牌型

func (*Rule) PokerHandIsMatch added in v0.0.3

func (slf *Rule) PokerHandIsMatch(cardsA, cardsB []Card) bool

PokerHandIsMatch 检查两组扑克牌牌型是否匹配

func (*Rule) SortByColorAsc added in v0.0.3

func (slf *Rule) SortByColorAsc(cards []Card) []Card

SortByColorAsc 将扑克牌按照花色从小到大排序

func (*Rule) SortByColorDesc added in v0.0.3

func (slf *Rule) SortByColorDesc(cards []Card) []Card

SortByColorDesc 将扑克牌按照花色从大到小排序

func (*Rule) SortByPointAsc added in v0.0.3

func (slf *Rule) SortByPointAsc(cards []Card) []Card

SortByPointAsc 将扑克牌按照点数从小到大排序

func (*Rule) SortByPointDesc added in v0.0.3

func (slf *Rule) SortByPointDesc(cards []Card) []Card

SortByPointDesc 将扑克牌按照点数从大到小排序

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL