common.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. package common
  2. import (
  3. "fmt"
  4. "bet24.com/servers/games/greedy/config"
  5. userservices "bet24.com/servers/micros/userservices/proto"
  6. )
  7. const (
  8. GAMEID = 41
  9. GAME_NAME = "greedybigo"
  10. )
  11. const (
  12. GameState_Bet = iota
  13. GameState_Open
  14. )
  15. const (
  16. TIMERID_CHECKROBOT = iota
  17. )
  18. type UserSetScore struct {
  19. UserId int
  20. Score int
  21. }
  22. type GameState struct {
  23. RoomName string
  24. SerialNumber int
  25. State int // 当前状态
  26. Sec int // 当前阶段已使用时间
  27. SpinResult BetOption // 本局开奖结果
  28. Historys []config.OpenHistory // 历史纪录
  29. AreaPopular AreaPopular // 区域热度
  30. TableUser ScoreUsers // 幸运星和赢金榜的玩家
  31. BetCmds []Bet // 本局下注列表
  32. CloseGame bool // 本轮开奖后是否关闭游戏
  33. }
  34. type BetBase struct {
  35. BetId int
  36. Amount int
  37. Session int // 场次
  38. }
  39. type Bet struct {
  40. BetBase
  41. UserId int
  42. Index int // 添加一个索引,用于失败撤销
  43. }
  44. type Batch_Bet struct {
  45. UserId int
  46. Bets []BetBase
  47. }
  48. type RankingUser struct {
  49. UserId int
  50. Score int
  51. }
  52. // 是否相同下注类型
  53. func (b *Bet) IsSameBet(b2 *Bet) bool {
  54. return b.BetId == b2.BetId
  55. //&& b.Session == b2.Session
  56. }
  57. type BetRet struct {
  58. ErrorMsg string
  59. }
  60. type Result struct {
  61. Bet
  62. WinAmount int
  63. SpinResult BetOption
  64. Tax int
  65. }
  66. type RecordInfo struct {
  67. SpinResult BetOption
  68. SerialNumber int
  69. }
  70. type UserClear struct {
  71. RoomName string
  72. UserId int
  73. }
  74. // 连胜用户和累计下注用户
  75. type ScoreUser struct {
  76. UserId int
  77. NickName string
  78. FaceId int
  79. FaceUrl string
  80. VipLevel int
  81. VipExpire int
  82. Decorations []userservices.UserDecoration
  83. IsRobot bool `json:"-"`
  84. Info []int
  85. }
  86. type ScoreUsers struct {
  87. WinGoldRankingUsers []ScoreUser
  88. DayWinGoldRankingUsers []ScoreUser
  89. }
  90. type AreaPopular struct {
  91. MostPopular int // 最受欢迎区域的索引
  92. BetCount []int // 下注人次
  93. DiamondHot []int // 钻石热度
  94. }
  95. func IsInTopN(rankList []ScoreUser, userId, n int) bool {
  96. for i, v := range rankList {
  97. if i >= n {
  98. break
  99. }
  100. if v.UserId == userId {
  101. return true
  102. }
  103. }
  104. return false
  105. }
  106. func GetRedisKey(key string) string {
  107. return fmt.Sprintf("%s:%s", GAME_NAME, key)
  108. }