package common

import (
	"fmt"
	"strings"
)

// todo
// 游戏模式ID
// 多个id会属于同一个游戏，需要判断游戏类型时添加一个方法
// 例如：判断是否是象棋游戏
// func IsChess(id int) bool {
//	switch id {
//	case GameId_Chesstitians,
//		GameId_ChesstitiansMakruk,
//		GameId_ChesstitiansCambodian,
//		GameId_ChesstitiansCambodianRobot:
//		return true
//	}
//	return false
//}

const (
	GameId_Unknow                     int = iota
	__GameId_Hundred_Min__                = 100 //################百人类################
	GameId_HundredDZNZ                    = 101 //德州牛仔
	GameId_HundredYXX                     = 102 //鱼虾蟹
	GameId_Baccarat                       = 103 //百家乐
	GameId_RollPoint                      = 104 //骰宝
	GameId_Roulette                       = 105 //轮盘
	GameId_DragonVsTiger                  = 106 //龙虎斗
	GameId_RedVsBlack                     = 107 //红黑大战
	GameId_RollCoin                       = 108 //奔驰宝马
	GameId_RollAnimals                    = 109 //飞禽走兽
	GameId_RollColor                      = 110 //森林舞会
	GameId_RedPack                        = 111 //红包扫雷
	GameId_Crash                          = 112 //碰撞游戏
	__GameId_VS_Min__                     = 200 //################对战类################
	GameId_DezhouPoker                    = 201 //德州扑克
	GameId_DezhouPoker_5To2               = 202 //德州扑克5选2
	GameId_OmahaPoker                     = 203 //奥马哈
	GameId_TenHalf                        = 204 //十点半
	GameId_FiveCardStud                   = 205 //梭哈
	GameId_BlackJack                      = 206 //21点
	GameId_TienLen                        = 207 // tienlen自由桌经典版
	GameId_TienLen_yl                     = 208 // tienlen自由桌娱乐版
	GameId_TienLen_toend                  = 209 // tienlen自由桌经典版（打到底）
	GameId_TienLen_yl_toend               = 210 // tienlen自由桌娱乐版（打到底）
	GameId_TienLen_m                      = 807 // tienlen经典比赛场
	GameId_TienLen_m_toend                = 808 // tienlen经典比赛场（打到底）
	GameId_TaLa                           = 220 //tala
	GameId_SamLoc                         = 230 //samloc
	GameId_TienLenSelect                  = 240 // tienlen经典版
	GameId_TienLenSelect_yl               = 241 // tienlen娱乐版
	GameId_TienLenRank                    = 242 // tienlen排位赛经典
	GameId_TienLenRank_yl                 = 243 // tienlen排位赛娱乐
	GameId_TienLenSelect_toend            = 244 // tienlen经典版（打到底）
	GameId_TienLenSelect_yl_toend         = 245 // tienlen娱乐版（打到底）
	GameId_TienLenRank_toend              = 246 // tienlen排位赛经典（打到底）
	GameId_TienLenRank_yl_toend           = 247 // tienlen排位赛娱乐（打到底）
	GameId_Chesstitians                   = 501 //国际象棋
	GameId_ChesstitiansMakruk             = 511 //国际象棋变体 (Makruk 泰国象棋)
	GameId_ChesstitiansCambodian          = 521 // 柬埔寨象棋 (Cambodian 柬埔寨象棋)
	GameId_ChesstitiansCambodianRobot     = 522 // 柬埔寨象棋人机对战
	GameID_Thirteen4                      = 211 // 十三张（四人场）
	GameID_Thirteen8                      = 212 // 十三张（八人场）
	GameID_ThirteenFree                   = 213 // 十三张（自由场经典场）
	GameID_ThirteenFreeLaiZi              = 214 // 十三张（自由场癞子场）
	__GameId_Slot_Min__                   = 300 //################拉霸类################
	GameId_CaiShen                        = 301 //财神
	GameId_Avengers                       = 302 //复仇者联盟
	GameId_EasterIsland                   = 303 //复活岛
	GameId_IceAge                         = 304 //冰河世纪
	GameId_TamQuoc                        = 305 //百战成神
	GameId_Fruits                         = 306 //水果拉霸
	GameId_Richblessed                    = 307 //多福多财
	__GameId_Fishing_Min__                = 400 //################捕鱼类################
	GameId_HFishing                       = 401 //欢乐捕鱼
	GameId_TFishing                       = 402 //天天捕鱼
	__GameId_Casual_Min__                 = 500 //################休闲类################
	__GameId_MiniGame_Min__               = 600 //################小游类################
	GameId_Candy                          = 601 //糖果小游戏
	GameId_MiniPoker                      = 602 //MiniPoker
	GameId_BOOM                           = 603 //卡丁车
	GameId_LuckyDice                      = 604 //幸运筛子
	GameId_CaoThap                        = 605 //CaoThap
	GameId_AngerUncle                     = 606 // 愤怒大叔
	GameId_SmallRoket                     = 607 // 小火箭
	__GameId_ThrGame_Min__                = 700 //################三方类################
	GameId_Thr_Dg                         = 701 //DG Game
	GameId_Thr_XHJ                        = 901 //DG Game
)

// IsTienLen TienLen游戏
func IsTienLen(gameId int) bool {
	return InSliceInt32(GetTienlenGameID(), int32(gameId))
}

func GetTienlenGameID() []int32 {
	//todo 还要维护游戏id,好麻烦，还容易忘
	return []int32{
		GameId_TienLen, GameId_TienLen_yl,
		GameId_TienLen_toend, GameId_TienLen_yl_toend,
		GameId_TienLen_m, GameId_TienLen_m_toend,
		GameId_TienLenSelect, GameId_TienLenSelect_toend,
		GameId_TienLenSelect_yl, GameId_TienLenSelect_yl_toend,
		GameId_TienLenRank, GameId_TienLenRank_toend,
		GameId_TienLenRank_yl, GameId_TienLenRank_yl_toend,
	}
}

// IsTienLenYuLe TienLen娱乐
func IsTienLenYuLe(gameId int) bool {
	switch gameId {
	case GameId_TienLen_yl,
		GameId_TienLen_yl_toend,
		GameId_TienLenSelect_yl,
		GameId_TienLenRank_yl,
		GameId_TienLenSelect_yl_toend,
		GameId_TienLenRank_yl_toend:
		return true
	}
	return false
}

// IsTienLenToEnd TienLen打到底
func IsTienLenToEnd(gameId int) bool {
	switch gameId {
	case GameId_TienLen_toend,
		GameId_TienLen_yl_toend,
		GameId_TienLen_m_toend,
		GameId_TienLenSelect_toend,
		GameId_TienLenSelect_yl_toend,
		GameId_TienLenRank_toend,
		GameId_TienLenRank_yl_toend:
		return true
	}
	return false
}

// IsChess 象棋游戏
func IsChess(gameId int) bool {
	switch gameId {
	case GameId_Chesstitians,
		GameId_ChesstitiansMakruk,
		GameId_ChesstitiansCambodian,
		GameId_ChesstitiansCambodianRobot:
		return true
	}
	return false
}

// IsThirteen 十三张游戏
func IsThirteen(gameId int) bool {
	switch gameId {
	case GameID_Thirteen4,
		GameID_Thirteen8,
		GameID_ThirteenFree,
		GameID_ThirteenFreeLaiZi:
		return true
	}
	return false
}

// IsThirteen 十三张游戏
func IsSmallRocket(gameId int) bool {
	switch gameId {
	case GameId_SmallRoket:
		return true
	}
	return false
}

// IsLocalGame 自动分场模式的游戏
// 根据 DB_Createroom.xlsx 给玩家分场或创建房间
func IsLocalGame(gameId int) bool {
	switch gameId {
	case GameId_TienLen, GameId_TienLen_yl,
		GameId_TienLen_toend, GameId_TienLen_yl_toend,
		GameId_TaLa,
		GameId_SamLoc,
		GameID_ThirteenFree, GameID_ThirteenFreeLaiZi:
		return true
	}
	return false
}

// IsPlayerPool 需要统计在个人水池的游戏
func IsPlayerPool(gameId int) bool {
	if IsTienLen(gameId) || IsThirteen(gameId) {
		return true
	}
	return false
}

// 房间编号区间
const (
	PrivateSceneStartId  = 10000000
	PrivateSceneMaxId    = 99999999
	MatchSceneStartId    = 100000000
	MatchSceneMaxId      = 199999999
	HundredSceneStartId  = 200000000
	HundredSceneMaxId    = 299999999
	HallSceneStartId     = 300000000
	HallSceneMaxId       = 399999999
	MiniGameSceneStartId = 400000000
	MiniGameSceneMaxId   = 409999999
	CoinSceneStartId     = 1000000000 //区间预留大点,因为队列匹配比较耗id,假定一天100w牌局,那么这个id区间够用1000天
	CoinSceneMaxId       = 1999999999
	DgSceneId            = 99
)

// 房间模式
const (
	SceneMode_Public  = iota //公共房间
	SceneMode_Club           //俱乐部房间
	SceneMode_Private        //私人房间
	SceneMode_Match          //赛事房间
	SceneMode_Thr            //三方房间
)

// 场景级别
//const (
//	SceneLvl_Test       = -1 // 试玩场(不要钱)
//	SceneLvl_Experience = 0  // 体验场(花小钱)
//	SceneLvl_Primary    = 1  // 初级场
//	SceneLvl_Middle     = 2  // 中级场
//	SceneLvl_Senior     = 3  // 高级场
//	SceneLvl_Professor  = 4  // 专家场
//)

// 房费选项
//const (
//	RoomFee_Owner int32 = iota //房主
//	RoomFee_AA                 //AA
//	RoomFee_Max
//)

const (
	Platform_Rob     = "__$G_P$__"
	Platform_Sys     = "0"
	Channel_Rob      = "$${ROBOT}$$"
	PMCmd_SplitToken = "-"
	PMCmd_AddCoin    = "addcoin"
	PMCmd_Privilege  = "setprivilege"
	DeviceOS_Android = "android"
	DeviceOS_IOS     = "ios"
)

const (
	GainWay_NewPlayer             int32 = 0  //0.新建角色
	GainWay_Pay                         = 1  //1.后台增加(主要是充值)
	GainWay_ByPMCmd                     = 2  //2.pm命令
	GainWay_MatchBreakBack              = 3  //3.退赛退还
	GainWay_MatchSystemSupply           = 4  //4.比赛奖励
	GainWay_Exchange                    = 5  //5.兑换
	GainWay_ServiceFee                  = 6  //6.桌费
	GainWay_CoinSceneWin                = 7  //7.金豆场赢取
	GainWay_CoinSceneLost               = 8  //8.金豆场输
	GainWay_CoinSceneEnter              = 9  //9.进入金币场预扣
	GainWay_ShopBuy                     = 10 //10.商城购买或者兑换
	GainWay_CoinSceneLeave              = 11 //11.金豆场回兑
	GainWay_HundredSceneWin             = 12 //12.万人场赢取
	GainWay_HundredSceneLost            = 13 //13.万人场输
	GainWay_MessageAttach               = 14 //14.邮件
	GainWay_SafeBoxSave                 = 15 //15.保险箱存入
	GainWay_SafeBoxTakeOut              = 16 //16.保险箱取出
	GainWay_Fishing                     = 17 //17.捕鱼
	GainWay_CoinSceneExchange           = 18 //18.金豆场兑换
	GainWay_UpgradeAccount              = 19 //19.升级账号
	GainWay_API_AddCoin                 = 20 //20.API操作钱包
	GainWay_GoldCome                    = 21 //21.财神降临
	GainWay_Transfer_System2Thrid       = 22 //22.系统平台转入到第三方平台的金币
	GainWay_Transfer_Thrid2System       = 23 //23.第三方平台转入到系统平台的金币
	GainWay_RebateTask                  = 24 //24.返利获取
	GainWay_IOSINSTALLSTABLE            = 25 //25.ios安装奖励
	GainWay_VirtualChange               = 26 //26.德州虚拟账变
	GainWay_CreatePrivateScene          = 27 //27.创建私有房间
	GainWay_PrivateSceneReturn          = 28 //28.解散私有房间返还
	GainWay_OnlineRandCoin              = 29 //29.红包雨
	GainWay_Expire                      = 30 //30.到期清理
	GainWay_PromoterBind                = 31 //31.手动绑定推广员
	GainWay_GradeShopReturn             = 32 //32.积分商城撤单退还积分
	GainWay_Api_In                      = 33 //33.转移金币
	GainWay_Api_Out                     = 34 //34.转移金币
	GainWay_Shop_Buy                    = 35 //35.购买记录
	GainWay_MAIL_MTEM                   = 36 //36.邮件领取道具
	GainWay_Item_Sale                   = 37 //37.道具出售
	GainWay_ReliefFund                  = 38 //38.领取救济金
	GainWay_Shop_Revoke                 = 39 //39.撤单
	GainWay_ActSign                     = 40 //40.签到
	GainWay_MatchSignup                 = 41 //比赛报名费用
	GainWay_MatchSeason                 = 42 //比赛赛季奖励
	GainWay_ActSignNew                  = 43 //43.新签到
	GainWay_ActTurnplate                = 44 //44.轮盘
	GainWay_ActBlindBox                 = 45 //45.盲盒
	GainWay_ActFirstPay                 = 46 //46.首充
	GainWay_VIPGift                     = 47 //47.vip礼包
	GainWay_ActContinuousPay            = 48 //48.连续充值
	GainWay_ActJybAward                 = 49 //49.礼包码兑换
	GainWay_LeaveDeduct                 = 50 //50.离开扣分
	GainWay_LeaveCombat                 = 51 //51.离开补偿
	GainWay_RankMatch                   = 52 //52.排位赛段位奖励
	GainWay_AddBag                      = 53 //53 增加背包接口调用
	GainWay_SmallRocket                 = 54 //54.小火箭收入
	GainWay_BindTel                     = 55 //55.绑定手机号
	GainWay_ReliefFund2                 = 56 //56.救济金看视频双倍领取
	GainWay_ActTurnplate2               = 57 //57.轮盘看视频双倍领取
	GainWay_ActSignNew2                 = 58 //58.签到看视频双倍领取
	GainWay_ItemUse                     = 59 //59.道具使用
	GainWay_PhoneScore                  = 60 //60.积分抽奖活动
	GainWay_RankReward                  = 61 //61.段位奖励
	GainWay_TaskReward                  = 62 //62.任务奖励
	GainWay_Interact                    = 63 //63.房间内互动效果
	GainWay_Collect                     = 64 //64.集卡活动
)

// 后台选择 金币变化类型 的充值 类型id号起始
//const GainWaySort_Api = 1000

// 自定义局数起始索引
//const CUSTOM_PER_GAME_INDEX_BEG int32 = 10

const (
	ClientRole_Agentor int = iota
	ClientRole_Player
	ClientRole_GM
	ClientRole_Max
)

const (
	CoinSceneOp_Enter          int32 = iota //进入
	CoinSceneOp_Leave                       //离开
	CoinSceneOp_Change                      //换桌
	CoinSceneOp_AudienceEnter               //观众进入
	CoinSceneOp_AudienceLeave               //观众离开
	CoinSceneOp_AudienceChange              //观众换桌
	CoinSceneOP_Server
)

// 玩家离开原因
const (
	PlayerLeaveReason_Normal          int = iota //主动离开
	PlayerLeaveReason_Bekickout                  //钱不够被踢出
	PlayerLeaveReason_OnDestroy                  //房间销毁强制退出
	PlayerLeaveReason_CoinScene                  //玩家暂离金豆自由场
	PlayerLeaveReason_ChangeCoinScene            //玩家换桌
	PlayerLeaveReason_OnBilled                   //结算完毕
	PlayerLeaveReason_DropLine                   //掉线离开
	PlayerLeaveReason_LongTimeNoOp               //长时间未操作
	PlayerLeaveReason_GameTimes                  //超过游戏次数强制离开
	PlayerLeaveReason_RoomFull                   //房间人数已达上限
	PlayerLeaveReason_RoomClose                  //房间已解散
	PlayerLeaveReason_RoomMaxCoin                //超出房间限制金币范围
	PlayerLeaveReason_AutoState                  //托管状态踢出房间
)

// 万分比
const RATE_BASE_VALUE int32 = 10000

const (
	SceneState_Normal  int = iota
	SceneState_Fishing     //鱼潮
)

const (
	PlayerType_Rob      int32 = 0
	PlayerType_Undefine       = 1
	PlayerType_Black          = -1
	PlayerType_White          = -2
)

const (
	CoinPoolAIModel_Default  int32 = iota //默认
	CoinPoolAIModel_Normal                //正常模式
	CoinPoolAIModel_ShouFen               //收分模式
	CoinPoolAIModel_ZheZhong              //折中模式
	CoinPoolAIModel_TuFen                 //吐分
	CoinPoolAIModel_Max                   //
)

const (
	RobotServerType  int = 9
	RobotServerId        = 901
	DataServerType   int = 10
	DataServerId         = 1001
	AIServerType         = 11
	AIServerId           = 1101
	ActThrServerType int = 12
	ActThrServerID       = 1201
)

// 踢号原因
const (
	KickReason_Unknow     int32 = iota
	KickReason_OtherLogin       //顶号
	KickReason_Freeze           //冻结
	KickReason_ResLow     = 5   //资源
	KickReason_AppLow     = 6   //App版本

	KickReason_CheckCodeErr  = 7  //校验错误
	KickReason_TaskErr       = 8  //任务错误
	KickReason_CantFindAcc   = 9  //查找sid acc错误
	KickReason_DBLoadAcc     = 10 //数据库登录错误
	KickReason_Logining           //登陆中
	KickReason_Disconnection = 99 //网络断开
)

// 游戏类型
const (
	GameType_Unknow  int32 = iota
	GameType_Hundred       // 百人类
	GameType_PVP           // 对战类
	GameType_Slot          // 拉霸类
	GameType_Fishing       // 捕鱼类
	GameType_Casual        // 休闲类
	GameType_Mini          // 小游戏类
	GameType_Thr           // 三方类
)

func IsHundredType(gt int32) bool {
	return gt == GameType_Hundred || gt == GameType_Slot || gt == GameType_Casual
}

func IsCoinSceneType(gt int32) bool {
	return gt == GameType_PVP || gt == GameType_Fishing
}

const PreCreateSceneAudienceNum = 20

const (
	HorseRaceLampPriority_Coin int = iota //根据玩家输赢金额大小设置优先级(在最大最小限额的基础上)
	HorseRaceLampPriority_Rand            //随机(在最大最小限额的基础上)
)

// 设备
const (
	Web        = 0
	Android    = 1
	IOS        = 2
	WebStr     = "h5"
	AndroidStr = "android"
	IOSStr     = "ios"
)

var DeviceName = map[int]string{
	Web:     WebStr,
	Android: AndroidStr,
	IOS:     IOSStr,
}

var DeviceNum = map[string]int{
	WebStr:     Web,
	AndroidStr: Android,
	IOSStr:     IOS,
}

const (
	MatchTrueMan_Forbid    int32 = -1 //禁止匹配真人
	MatchTrueMan_Unlimited       = 0  //不限制
	MatchTrueMan_Priority        = 1  //优先匹配真人
)

const (
	SingleAdjustModeNormal = 0
	SingleAdjustModeWin    = 1
	SingleAdjustModeLose   = 2
)

// 自动化标签(程序里产生的全部<0)
const (
	AutomaticTag_QZNN_Smart int32 = -1
)

const (
	SceneParamEx_DbGameFreeId = 0
	SceneParamEx_CanStartNum  = 1 //游戏开始的要求人数
)

// 比赛参数
const (
	PlayerIParam_MatchRank int = iota
	PlayerIParam_IsQuit
	PlayerIParam_MatchWeaken
	PlayerIParam_TotalOfGames
)

const (
	PARAMEX_GAMEFREEID          int = iota //游戏id
	PARAMEX_MATCH_COPYID                   //比赛副本id
	PARAMEX_MATCH_ID                       //比赛id
	PARAMEX_MATCH_PHASEIDX                 //赛程阶段idx
	PARAMEX_MATCH_MMTYPE                   //赛制
	PARAMEX_MATCH_BASESCORE                //底分
	PARAMEX_MATCH_NUMOFGAME                //局数
	PARAMEX_MATCH_OUTSCORE                 //出局分数
	PARAMEX_MATCH_RESTPLAYERNUM            //剩余人数
	PARAMEX_MATCH_STARTNUM                 //本轮开始人数
	//PARAMEX_MATCH_RANK                     //我的排名,构建房间消息时,额外补充,每个玩家不同
)

const (
	MaxLoopNum    = 1000
	DefaultResult = 0
)

const (
	CodeTypeSMS     = 0 // 短信验证码
	CodeTypeStr     = 1 // 字符串验证码
	CodeTypeHuaKuai = 2 // 滑块验证码
	CodeTypeNo      = 3 // 不使用验证码
)

const (
	ActId_Share            int = iota //0.微信分享
	ActId_OnlineReward                //1.在线奖励
	ActId_UpgradeAccount              //2.升级账号
	ActId_GoldTask                    //3.财神任务
	ActId_GoldCome                    //4.财神降临
	ActId_LuckyTurntable              //5.转盘活动
	ActId_Yeb                         //6.余额宝
	ActId_Card                        //7.周卡月卡
	ActId_RebateTask                  //8.返利获取
	ActId_IOSINSTALLSTABLE            //9.ios安装奖励
	ActId_VipLevelBonus               //10.vip日周月等级奖励
	ActId_LoginRandCoin               //11.登录红包
	ActId_OnlineRandCoin              //12.红包雨
	ActId_MatchSwitch                 //13.比赛开关
	ActId_PromoterBind                //14.手动绑定推广员
	ActId_Lottery                     //15.彩金池
	ActId_Task                        //16.活跃任务
	ActId_PROMOTER                    //17.全民推广
	ActId_Activity                    //18.活动界面
	ActId_NewYear                     //19.新年暗号红包活动
	ActId_Guess                       //20.猜灯谜活动
	ActId_Sign                        //21.七日签到
	ExchangeId_Alipay                 //22.兑换到支付宝
	ExchangeId_Bank                   //23.兑换到银行卡
	ExchangeId_Wechat                 //24.兑换到微信
	ActId_Max
)

// 匹配模式
const (
	MatchMode_Normal int32 = iota //普通匹配
	MatchMode_Quene               //队列匹配
)

const (
	SCENE_BIGWINHISTORY_MAXNUMBER    = 40 // 爆奖记录最大数量
	SCENE_BIGWINHISTORY_LIMITNUMBER  = 10 // 假数据生成临界值
	SCENE_BIGWINHISTORY_TIMEINTERVAL = 2  // 假数据生成定点时间间隔，单位：小时（实际时间 = 定点时间 + 随机时间）
)
const (
	OrderColumnInvalid           = 0  // 默认
	OrderColumnCoinPayTotal      = 1  // 充值
	OrderColumnCoinExchangeTotal = 2  // 提现
	OrderColumnTaxTotal          = 3  // 税收
	OrderColumnRegisterTime      = 4  // 注册时间
	OrderColumnRoomNumber        = 5  // 游戏房间号
	OrderColumnLose              = 6  // 输次数
	OrderColumnWin               = 7  // 赢次数
	OrderColumnDraw              = 8  // 平次数
	OrderColumnWinCoin           = 9  // 赢分
	OrderColumnLoseCoin          = 10 // 输分
)

const (
	LoginTypeGuest    = 0 // 游客登录
	LoginTypeAccount  = 1 // 账号登录
	LoginTypeTelCode  = 2 // 手机号验证码登录
	LoginTypeTelegram = 5 // telegram登录
	LoginTypeGoogle   = 6 // google,facebook 登录

	RegisterTypeTel  = 3 // 手机号注册
	RegisterTypeName = 4 // 账号注册
)

const (
	// 账号判断状态码
	LoginTypeNoExist   = -1
	LoginError         = 0
	LoginOk            = 1
	LoginNew           = 2
	LoginPasswordError = 3
	LoginFreeze        = 4
	LoginTelExist      = 8
	LoginTelCodeExpire = 9 //  手机号验证码登录过期

	RegisterNotExist = 6
	RegisterExist    = 7
	// 创建账号状态码
	InsertAccountOk = 9
)

const TelLoginValidDays = 7 // 手机号登录有效期，天

const (
	LoginLogTypeLogin  int32 = iota // 登录
	LoginLogTypeLogout              // 登出
	LoginLogTypeRehold              // 重连
	LoginLogTypeDrop                // 掉线
)

// 道具ID
const (
	ItemIDCoin       = 100001 // 金币对应的itemId
	ItemIDDiamond    = 100002 // 钻石对应的itemId
	ItemIDMoneyPond  = 100003 // 玩家金币池对应物品Id
	ItemIDVipExp     = 100005 // VIP经验对应的物品Id
	ItemIDPhoneScore = 100006 // 手机抽奖积分
	ItemIDWeekScore  = 100004 // 周活跃积分
	ItemIDGiftBox    = 50001  // 碎片礼盒
)

func ToItemId(id int32) int32 {
	switch id {
	case 1:
		return ItemIDCoin
	case 2:
		return ItemIDDiamond
	}
	return id
}

// 道具类型
const (
	ItemTypePetFragments       = 1  //宠物碎片
	ItemTypeCharacterFragments = 2  //角色碎片
	ItemTypeChangeCard         = 3  //兑换卡
	ItemTypeOther              = 4  //其他
	ItemTypeCoin               = 5  //金币
	ItemTypeDiamond            = 6  //钻石
	ItemTypeFishPower          = 7  //捕鱼炮台
	ItemTypeMoneyPond          = 8  //玩家金币池
	ItemTypePhoneCode          = 9  //话费兑换卡
	ItemTypeVipExp             = 10 //VIP经验
	ItemTypeShopScore          = 11 //积分
	ItemTypeInteract           = 12 // 互动表情
)

func GetKeyNoviceGameId(gameId int) string {
	return fmt.Sprintf("novice-%v", gameId)
}

func GetKeyGameType(gameType int) string {
	return fmt.Sprintf("gametype-%v", gameType)
}

// 账变类型
const (
	BillTypeCoin    = 0 // 金币
	BillTypeDiamond = 1 // 钻石
)

// 验证码类型
const (
	SMSCodeTelBind  = 1 // 绑定手机号验证码
	SMSCodeTelLogin = 2 // 手机号登录验证码
)

// 账号类型
const (
	AccountTypeGoogle   = 1 // 谷歌
	AccountTypeFacebook = 2 // facebook
	AccountTypeTel      = 3 // 手机号
)

func GetTelLoginCodeKey(platform, tel string) string {
	return fmt.Sprintf("%v.%v.%v", SMSCodeTelLogin, platform, tel)
}

func GetBindTelCodeKey(platform, tel string) string {
	return fmt.Sprintf("%v.%v.%v", SMSCodeTelBind, platform, tel)
}

func GetImageCodeKey(key string) string {
	return fmt.Sprintf("%v.%v", "Image", key)
}

const (
	SMSCodeValidTime         = 60  // 访问频率限制
	SMSCodeValidTimeTelBind  = 60  // 绑定手机号验证码有效期，单位秒
	SMSCodeValidTimeTelLogin = 600 // 手机号登录验证码有效期，单位秒
)

// 活动，任务类型
const (
	TaskTypeAdv             = 1  // 看广告次数
	TaskTypeBuyCoin         = 2  // 买金币次数
	TaskTypeLogin           = 3  // 登录次数
	TaskTypeWinTimes        = 4  // 赢游戏次数
	TaskTypePlayTimes       = 5  // 玩游戏次数
	TaskTypeRankMatchTimes  = 6  // 排位赛次数
	TaskTypePay             = 7  // 充值金额
	TaskTypeWinOrLose       = 8  // 游戏输赢金币数量
	TaskTypeTienlenCount    = 9  // tienlen游戏场次
	TaskTypeBindInviter     = 10 // 绑定邀请人数量
	TaskTypeWinCoin         = 11 // 赢取金币数量
	TaskTypeTienlenWinTimes = 12 // tienlen游戏赢取次数
	TaskTypeInviteScore     = 13 // 邀请积分
	TaskTypeActivityScore   = 14 // 周活跃积分数量
	TaskTypeFirstLogin      = 15 // 每日首次登录
	TaskTypeInviteNum       = 16 // 邀请绑定数量
)

const (
	TaskGameTypeTienlen     = 1 // tienlen
	TaskGameTypeThirteen    = 2 // 十三张
	TaskGameTypeChess       = 3 // 象棋
	TaskGameTypeSmallRocket = 4 // 小火箭
)

const (
	TaskActivityTypeEveryDay = 1 // 每日任务
	TaskActivityTypeWeek     = 2 // 每周任务
	TaskActivityTypeNovice   = 3 // 新手任务
	TaskActivityTypeInvite   = 4 // 邀请任务
)

const HeadRange = 3 // 机器人头像id范围

const (
	InviteScoreTypeBind      = 1 // 绑定邀请码
	InviteScoreTypeLogin     = 2 // 每日登录
	InviteScoreTypePlayTimes = 3 // 每日参与任意游戏
	InviteScoreTypeRecharge  = 4 // 充值
	InviteScoreTypeGameTimes = 5 // 每局游戏
)

const TaskIDInvitePlayGame = 1000001
const TaskIDInviteRecharge = 1000002
const TaskIDInviteFirstLogin = 1000003

func InMatchChannel(ls []string, n string) bool {
	if n == "" || len(ls) == 0 {
		return false
	}
	if n == Channel_Rob {
		return true
	}
	if InSliceString(ls, n) {
		return true
	}
	if InSliceString(ls, "Official") && strings.ToLower(n) == "main" { // 兼容
		return true
	}
	return false
}

// 渠道名称
const (
	ChannelDefault    = ChannelOfficial
	ChannelGooglePlay = "GooglePlay"
	ChannelWeb        = "Web"
	ChannelOfficial   = "Official"
)

// 角色id
const (
	DefaultRoleId = RoleIDGirl // 默认角色
	RoleIDGirl    = 2000001
	RoleIDBoy     = 2000002
	RoleIDMagic   = 2000003
)

var RolesIDs = []int32{RoleIDGirl, RoleIDBoy, RoleIDMagic}

// 角色加成类型
const (
	RoleAddADV       = 1 // 看视频加成
	RoleAddCoin      = 2 // 商城购买金币加成
	RoleAddRankScore = 3 // 排位积分加成
)

// 宠物id
const (
	DefaultPetId = PetIDChicken // 默认宠物
	PetIDChicken = 3000001
)

var PetIDs = []int32{PetIDChicken}
