斗地主服务端的主要逻辑
出牌判断
package main
import (
"errors"
"math/rand"
"sort"
)
// 简单的斗地主程序
// 一副牌
type OneDeckOfCards struct {
Intact map[int]*Card // 完整的牌
Discard map[int]*Card // 打过的牌
LastPlay *LastCards // 最后一次出的牌
}
// 单张牌的结构
type Card struct {
Name string // 扑克牌的名称
Number int // 这张牌在这负牌创建时的位置
Current int // 在当前牌中的位置
Color string // 这张牌的花色
Size int // 这张牌对应的大小
UsedUser int // 这张牌是谁打掉的,用于记牌器,防止客户端篡改牌
}
// 最后一次出牌
type LastCards struct {
PokerType int // 牌型
CountSameCardMax int // 便于快速判断
SortCard []int // 排序后的出牌
CountCard map[int]int // 统计的出牌(包含所有的牌)
}
// 单次出牌
type PlayingCards struct {
Cards []Card
}
const (
PokerNumbers = 54
PokerKing = 14 // 小王编号
PokerBigKing = 15 // 大王编号
PokerTypeError = -1 // 出牌错误
PokerTypeEmpty = 0 // 没人出牌,什么牌都可以出
PokerTypeSingle = 1 // 单牌
PokerTypeDouble = 2 // 对子
PokerTypeThree = 3 // 三张
PokerTypeThreeBeltsOne = 4 // 三带一
PokerTypeThreeBeltsTwo = 5 // 三带二
PokerTypeShunZi = 6 // 顺子678910
PokerTypeLianDui = 7 // 连对778899
PokerTypeFlay = 8 // 飞机666777888
PokerTypeFlayBeltsOne = 9 // 飞机带单
PokerTypeFlayBeltsTwo = 10 // 飞机带队
PokerTypeBoomBeltsOne = 11 // 炸弹带单张,两个单张或者一个对子
PokerTypeBoomBeltsTwo = 12 // 炸弹带对子
PokerTypeBoom = 13 // 炸弹
PokerTypeBoomKing = 99 // 王炸
)
func main() {
// 创建牌
cards, _ := CreatePoker()
// 洗牌
cards.ShuffleToPoker()
// 判断牌的大小
}
// 判断牌是否合理,顺子 三带一 四带二
// 判断牌的类型
func (poker *PlayingCards) CheckType() (*CurrentCards, error) {
// 对牌进行判断,判断牌型
// 单 双 三 三带1 三带2 连对 顺子 飞机(带1 带二) 炸弹 王炸
list := make([]int, len(poker.Cards))
for key, card := range poker.Cards {
list[key] = card.Size
}
// 对牌进行排序,[2 2 4 6 7 7 10 11 13 13]
sort.Ints(list)
// fmt.Println(list)
// 开始判断牌型
// 相同牌最多的是多少
countSameCardMax := 1
countCard := make(map[int]int, len(poker.Cards))
sortCard := make([]int, 0)
for _, value := range list {
if _, ok := countCard[value]; !ok {
countCard[value] = 1
sortCard = append(sortCard, value)
continue
}
countCard[value]++
if countSameCardMax < countCard[value] {
countSameCardMax = countCard[value]
}
}
playPoker := &CurrentCards{
CardTotal: len(poker.Cards),
SortCard: sortCard,
CountCard: countCard,
}
// 1 单 或者顺子 王炸 2对子 连队 3 三带一 三带2 飞机带 4 炸弹
var err error
switch countSameCardMax {
case 1:
// 1 单,顺子 或者 王炸
playPoker.PokerType, err = poker.countSameCardMaxOne(countCard, sortCard)
return playPoker, err
case 2:
// 2对子 连队
playPoker.PokerType, err = poker.countSameCardMaxTwo(countCard, sortCard)
return playPoker, err
case 3:
// 3 三带一 三带2 飞机带
playPoker.PokerType, err = poker.countSameCardMaxThree(countCard)
return playPoker, err
case 4:
// 4 炸弹
playPoker.PokerType, err = poker.bomb(countCard)
return playPoker, err
default:
return playPoker, errors.New("错误的牌")
}
}
// 最大值是一张牌的判断(重复牌)
func (poker *PlayingCards) countSameCardMaxOne(countCard map[int]int, sortCard []int) (int, error) {
// 单牌
if len(poker.Cards) == len(countCard) && len(countCard) == 1 {
// 单牌,判断是否可以出牌
return PokerTypeSingle, nil
}
_, king := countCard[PokerKing]
_, bigKing := countCard[PokerBigKing]
if king && bigKing {
// 王炸
return PokerTypeBoomKing, nil
}
if err := poker.checkContinuous(sortCard); err != nil {
return PokerTypeError, err
}
if len(sortCard) < 5 {
// 未达到最小值
return PokerTypeError, errors.New("未达到5或以上的顺子,不符合规则")
}
return PokerTypeShunZi, nil
}
// 最大值是两张牌的判断(重复牌)
func (poker *PlayingCards) countSameCardMaxTwo(countCard map[int]int, sortCard []int) (int, error) {
count := len(poker.Cards)
if count/2 != len(countCard) {
return PokerTypeError, errors.New("错误的牌,存在单张的牌")
}
if count == 2 {
return PokerTypeDouble, nil
}
// 判断是否是连队
if err := poker.checkContinuous(sortCard); err != nil {
return PokerTypeError, err
}
// 至少要用三队才能是连队
if len(countCard) < 3 {
return PokerTypeError, errors.New("未达到连队要求,三队及以上")
}
return PokerTypeLianDui, nil
}
// 最大值是三张牌的判断(重复牌)
func (poker *PlayingCards) countSameCardMaxThree(countCard map[int]int) (int, error) {
// 3 三带一 三带2 飞机带
count := len(poker.Cards)
if count == 3 {
// 三 没带
return PokerTypeThree, nil
}
if count == 4 {
// 三带1
return PokerTypeThreeBeltsOne, nil
}
if count == 5 && len(countCard) == 2 {
// 三带二
return PokerTypeThreeBeltsTwo, nil
}
sortCard := make([]int, 0)
for key, value := range countCard {
if value == 3 {
sortCard = append(sortCard, key)
}
}
// 飞机带判断,注意极限情况 三带1 那个1 就是四个三个的
sort.Ints(sortCard)
if err := poker.checkContinuous(sortCard); err != nil {
// 极限情况判断,注意一副牌的斗地主不会出现6对带的情况
// 头尾去除后都要不是连的情况才是失败的情况
if len(sortCard) == 4 &&
len(sortCard) == len(countCard) &&
((poker.checkContinuous(sortCard[1:]) != nil) ||
(poker.checkContinuous(sortCard[:3]) != nil)) {
return PokerTypeFlayBeltsOne, nil
}
return PokerTypeError, err
}
if len(sortCard) == len(countCard) {
// 飞机啥也没带
return PokerTypeFlay, nil
}
// 判断带的是否正常
// 飞机带队
difference := len(countCard) - len(sortCard)
if difference == len(sortCard) && count == (len(sortCard)*3+(difference*2)) {
return PokerTypeFlayBeltsTwo, nil
}
// 飞机带单 注意单中有可能是对拆开的,这时候判断牌的数量即可
if len(poker.Cards) == len(sortCard)*4 {
return PokerTypeFlayBeltsOne, nil
}
return PokerTypeError, errors.New("未知的牌类型,不允许的牌规则")
}
// 炸弹
func (poker *PlayingCards) bomb(countCard map[int]int) (int, error) {
count := len(poker.Cards)
if count == 4 {
// 炸弹
return PokerTypeBoom, nil
}
if count%2 != 0 || len(countCard) > 3 {
return PokerTypeError, errors.New("错误的带牌")
}
if count == 6 {
// 4 带 二 连张单 或者一个队都是 算为两张单
return PokerTypeBoomBeltsOne, nil
}
// count == 8 四带两对
return PokerTypeBoomBeltsTwo, nil
}
// 判断牌是否连续
func (poker *PlayingCards) checkContinuous(sortCard []int) error {
tmp := 0
for _, value := range sortCard {
if value >= 13 {
// 失败,有大于A的牌
return errors.New("不合理的牌,存在大于A的牌")
}
if tmp == 0 {
tmp = value
continue
}
if value-1 == tmp {
// 正常
tmp = value
continue
}
return errors.New("不合理的牌,非连续的牌")
}
return nil
}
// 创建扑克牌
func CreatePoker() (*OneDeckOfCards, error) {
// 扑克的大小
pokerNumbers := map[string]int{"3": 1, "4": 2, "5": 3, "6": 4, "7": 5, "8": 6, "9": 7, "10": 8, "J": 9, "Q": 10, "K": 11, "A": 12, "2": 13, "小王": 14, "大王": 15}
// 扑克的花色,注意王的红比黑的大
pokerColor := map[string]int{"黑桃": 1, "红桃": 2, "方块": 3, "梅花": 4}
number := 1
pokers := OneDeckOfCards{
Intact: make(map[int]*Card, PokerNumbers),
Discard: make(map[int]*Card, PokerNumbers),
}
for key, value := range pokerNumbers {
for k, v := range pokerColor {
if value > 13 && v >= 2 {
break
}
pokers.Intact[number] = &Card{
Name: key,
Number: number,
Current: number,
Color: k,
Size: value,
}
number++
}
}
return &pokers, nil
}
// 随机洗牌 Fisher–Yates
func (poker *OneDeckOfCards) ShuffleToPoker() {
for key, value := range poker.Intact {
// 获取随机数,通过取余的方法让其落在范围内
// 交换目标位置和当前位置的值
current := (rand.Int()) % PokerTotal
if current == 0 {
continue
}
// 洗牌后需要把编号也修改一下,方便记牌器和后面的判断牌是否被打出去的时候使用
value.Current = current
poker.Intact[key] = poker.Intact[current]
poker.Intact[key].Current = key
poker.Intact[current] = value
}
return
}
测试代码,测试牌型的判断
package main
import (
"log"
"testing"
)
func TestOneDeckOfCards_CheckType(t *testing.T) {
// 创建一副牌,取前10张
cards, _ := CreatePoker()
cards.ShuffleToPoker()
play := &PlayingCards{
Cards: make([]Card, 10),
}
i := 0
for _, value := range cards.Intact {
if i > 9 {
break
}
play.Cards[i] = *value
i++
}
play.CheckType()
}
// 判断牌型
func TestPlayingCards_CheckType(t *testing.T) {
var play PlayingCards
play = PlayingCards{Cards: make([]Card, 1)}
play.Cards[0] = Card{Name: "4", Number: 8, Current: 15, Color: "黑桃", Size: 2}
log.Println(play.CheckType()) // 1 <nil> 单牌
play = PlayingCards{Cards: make([]Card, 2)}
play.Cards[0] = Card{Name: "3", Number: 8, Current: 15, Color: "黑桃", Size: 1}
play.Cards[1] = Card{Name: "3", Number: 9, Current: 20, Color: "红桃", Size: 1}
log.Println(play.CheckType()) // 2 <nil> 对子
play = PlayingCards{Cards: make([]Card, 3)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 9, Current: 21, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 10, Current: 22, Color: "梅花", Size: 3}
log.Println(play.CheckType()) // 3 <nil>
play = PlayingCards{Cards: make([]Card, 4)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 9, Current: 21, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 10, Current: 22, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "9", Number: 25, Current: 26, Color: "梅花", Size: 7}
log.Println(play.CheckType()) // 4 <nil>
play = PlayingCards{Cards: make([]Card, 5)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 9, Current: 21, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 10, Current: 22, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "9", Number: 25, Current: 26, Color: "梅花", Size: 7}
play.Cards[4] = Card{Name: "9", Number: 27, Current: 30, Color: "黑桃", Size: 7}
log.Println(play.CheckType()) // 5 <nil>
play = PlayingCards{Cards: make([]Card, 5)}
play.Cards[0] = Card{Name: "3", Number: 8, Current: 15, Color: "黑桃", Size: 1}
play.Cards[1] = Card{Name: "4", Number: 9, Current: 21, Color: "红桃", Size: 2}
play.Cards[2] = Card{Name: "5", Number: 10, Current: 22, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "6", Number: 25, Current: 26, Color: "梅花", Size: 4}
play.Cards[4] = Card{Name: "7", Number: 27, Current: 30, Color: "黑桃", Size: 5}
log.Println(play.CheckType()) // 6 <nil>
play = PlayingCards{Cards: make([]Card, 6)}
play.Cards[0] = Card{Name: "10", Number: 8, Current: 15, Color: "黑桃", Size: 8}
play.Cards[5] = Card{Name: "2", Number: 7, Current: 12, Color: "黑桃", Size: 13}
play.Cards[1] = Card{Name: "J", Number: 9, Current: 21, Color: "红桃", Size: 9}
play.Cards[2] = Card{Name: "Q", Number: 10, Current: 22, Color: "梅花", Size: 10}
play.Cards[3] = Card{Name: "K", Number: 25, Current: 26, Color: "梅花", Size: 11}
play.Cards[4] = Card{Name: "A", Number: 27, Current: 30, Color: "黑桃", Size: 12}
log.Println(play.CheckType()) // -1 不合理的牌,存在大于A的牌
play = PlayingCards{Cards: make([]Card, 4)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 7, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "6", Number: 9, Current: 21, Color: "红桃", Size: 4}
play.Cards[3] = Card{Name: "6", Number: 10, Current: 22, Color: "梅花", Size: 4}
log.Println(play.CheckType()) // -1 未达到连队要求,三队及以上
play = PlayingCards{Cards: make([]Card, 6)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 7, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "6", Number: 9, Current: 21, Color: "红桃", Size: 4}
play.Cards[3] = Card{Name: "6", Number: 10, Current: 22, Color: "梅花", Size: 4}
play.Cards[4] = Card{Name: "7", Number: 12, Current: 25, Color: "红桃", Size: 5}
play.Cards[5] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
log.Println(play.CheckType()) // 7 <nil>
play = PlayingCards{Cards: make([]Card, 6)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 7, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 9, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "6", Number: 10, Current: 22, Color: "黑桃", Size: 4}
play.Cards[4] = Card{Name: "6", Number: 12, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 15, Current: 30, Color: "梅花", Size: 4}
log.Println(play.CheckType()) // 8 <nil>
play = PlayingCards{Cards: make([]Card, 12)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 7, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 9, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "6", Number: 10, Current: 22, Color: "黑桃", Size: 4}
play.Cards[4] = Card{Name: "6", Number: 12, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 15, Current: 30, Color: "梅花", Size: 4}
play.Cards[6] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[7] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[8] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[9] = Card{Name: "8", Number: 15, Current: 30, Color: "梅花", Size: 6}
play.Cards[10] = Card{Name: "8", Number: 15, Current: 30, Color: "梅花", Size: 6}
play.Cards[11] = Card{Name: "8", Number: 15, Current: 30, Color: "梅花", Size: 6}
log.Println(play.CheckType()) // 8 <nil>
play = PlayingCards{Cards: make([]Card, 12)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 7, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 9, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "6", Number: 10, Current: 22, Color: "黑桃", Size: 4}
play.Cards[4] = Card{Name: "6", Number: 12, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 15, Current: 30, Color: "梅花", Size: 4}
play.Cards[6] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[7] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[8] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[9] = Card{Name: "10", Number: 15, Current: 30, Color: "梅花", Size: 8}
play.Cards[10] = Card{Name: "10", Number: 15, Current: 30, Color: "梅花", Size: 8}
play.Cards[11] = Card{Name: "10", Number: 15, Current: 30, Color: "梅花", Size: 8}
log.Println(play.CheckType()) // 9 <nil>
play = PlayingCards{Cards: make([]Card, 12)}
play.Cards[0] = Card{Name: "5", Number: 8, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 7, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 9, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "6", Number: 10, Current: 22, Color: "黑桃", Size: 4}
play.Cards[4] = Card{Name: "6", Number: 12, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 15, Current: 30, Color: "梅花", Size: 4}
play.Cards[6] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[7] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[8] = Card{Name: "7", Number: 15, Current: 30, Color: "梅花", Size: 5}
play.Cards[9] = Card{Name: "J", Number: 15, Current: 30, Color: "梅花", Size: 9}
play.Cards[10] = Card{Name: "K", Number: 15, Current: 30, Color: "梅花", Size: 11}
play.Cards[11] = Card{Name: "2", Number: 15, Current: 30, Color: "梅花", Size: 13}
log.Println(play.CheckType()) // 9 <nil>
play = PlayingCards{Cards: make([]Card, 10)}
play.Cards[0] = Card{Name: "5", Number: 5, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 6, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 7, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "6", Number: 8, Current: 22, Color: "黑桃", Size: 4}
play.Cards[4] = Card{Name: "6", Number: 9, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 10, Current: 26, Color: "梅花", Size: 4}
play.Cards[6] = Card{Name: "7", Number: 11, Current: 27, Color: "梅花", Size: 5}
play.Cards[7] = Card{Name: "7", Number: 12, Current: 28, Color: "梅花", Size: 5}
play.Cards[8] = Card{Name: "K", Number: 13, Current: 29, Color: "梅花", Size: 11}
play.Cards[9] = Card{Name: "K", Number: 15, Current: 30, Color: "梅花", Size: 11}
log.Println(play.CheckType()) // 10 <nil>
play = PlayingCards{Cards: make([]Card, 6)}
play.Cards[0] = Card{Name: "5", Number: 5, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 6, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 7, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "5", Number: 8, Current: 22, Color: "黑桃", Size: 3}
play.Cards[4] = Card{Name: "6", Number: 9, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 10, Current: 26, Color: "梅花", Size: 4}
log.Println(play.CheckType()) // 11 <nil>
play = PlayingCards{Cards: make([]Card, 6)}
play.Cards[0] = Card{Name: "5", Number: 5, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 6, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 7, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "5", Number: 8, Current: 22, Color: "黑桃", Size: 3}
play.Cards[4] = Card{Name: "6", Number: 9, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "7", Number: 10, Current: 26, Color: "梅花", Size: 5}
log.Println(play.CheckType()) // 11 <nil>
play = PlayingCards{Cards: make([]Card, 8)}
play.Cards[0] = Card{Name: "5", Number: 5, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 6, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 7, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "5", Number: 8, Current: 22, Color: "黑桃", Size: 3}
play.Cards[4] = Card{Name: "6", Number: 9, Current: 25, Color: "红桃", Size: 4}
play.Cards[5] = Card{Name: "6", Number: 10, Current: 26, Color: "梅花", Size: 4}
play.Cards[6] = Card{Name: "9", Number: 10, Current: 26, Color: "梅花", Size: 7}
play.Cards[7] = Card{Name: "9", Number: 10, Current: 26, Color: "梅花", Size: 7}
log.Println(play.CheckType()) // 12 <nil>
play = PlayingCards{Cards: make([]Card, 4)}
play.Cards[0] = Card{Name: "5", Number: 5, Current: 15, Color: "黑桃", Size: 3}
play.Cards[1] = Card{Name: "5", Number: 6, Current: 12, Color: "红桃", Size: 3}
play.Cards[2] = Card{Name: "5", Number: 7, Current: 21, Color: "梅花", Size: 3}
play.Cards[3] = Card{Name: "5", Number: 8, Current: 22, Color: "黑桃", Size: 3}
log.Println(play.CheckType()) // 13 <nil>
play = PlayingCards{Cards: make([]Card, 2)}
play.Cards[0] = Card{Name: "小王", Number: 5, Current: 15, Color: "黑桃", Size: 14}
play.Cards[1] = Card{Name: "大王", Number: 6, Current: 12, Color: "红桃", Size: 15}
log.Println(play.CheckType()) // 99 <nil>
}