package thirteen

import "time"

var (
	SpecialScore = []int64{0, 108, 36, 0, 20, 0, 0, 0, 10, 0, 0, 4, 4, 3}
)

// 房间的参数
const (
	ParamMaxPlayerNum = 0 // 最大人数
	ParamAuto         = 1 // 自动摆牌
	ParamBaiPai       = 2 // 摆牌时间
	ParamBaseScore    = 3 // 游戏底分
	ParamLaiZi        = 4 // 是否有癞子
)

// 场景状态
const (
	ThirteenWaterSceneStateWait      int = iota //等待状态
	ThirteenWaterSceneStateStart                //开始倒计时
	ThirteenWaterSceneStateSendCards            //开始发牌
	ThirteenWaterSceneStateOptCard              //选牌理牌
	ThirteenWaterSceneStateShowCards            //轮流看牌
	ThirteenWaterSceneStateHit                  //打枪
	ThirteenWaterSceneStateBilled               //结算
	ThirteenWaterSceneStateMax
)

// 玩家操作
const (
	ThirteenWaterPlayerOpMS      = 1 //确定牌
	ThirteenWaterPlayerOpStandup = 2 //站起标记
	ThirteenWaterPlayerOpTest    = 3 // test
	ThirteenWaterPlayerOpReset   = 4 // 重新选牌
)
const (
	ThirteenWaterSceneWaitTimeout = time.Second * 2  //等待倒计时
	ThirteenWaterStartTimeout     = time.Second * 3  //开始倒计时
	ThirteenWaterSendCardsTimeout = time.Second * 3  //开始发牌
	ThirteenWaterOptCardTimeout   = time.Second * 30 //30选牌换牌
	ThirteenWaterShowCardsTimeout = time.Second * 1  //轮流看牌时间
	ThirteenWaterHitTimeout       = time.Second * 2  //打枪
	ThirteenWaterBilledTimeout    = time.Second * 5  //结算
)

func GetMaxCard(allGroup map[int]*Group) *Group {
	var ret *Group
	max := -1000
	for k, v := range allGroup {
		sum := 0
		if k >= 1000000 {
			ret = v
			break
		}
		a := k / 10000
		b := (k - a*10000) / 100
		c := k - a*10000 - b*100
		s := []int{a, b, c}
		for _, m := range s {
			if m >= 1 && m <= 20 {
				sum += 20 - m
			}
		}
		if max <= sum {
			max = sum
			ret = v
		}
	}
	return ret
}
