common.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package common
  2. import (
  3. "fmt"
  4. "bet24.com/servers/games/luckyfruit_table/config"
  5. userservices "bet24.com/servers/micros/userservices/proto"
  6. )
  7. const (
  8. GAMEID = 39
  9. GAME_NAME = "luckyfruit"
  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 Fruit // 本局开奖结果
  28. Historys []config.OpenHistory // 历史纪录
  29. TableUser ScoreUsers // 幸运星和赢金榜的玩家
  30. //RichList []int //富豪榜
  31. BetList []int //下注榜
  32. //Scores []UserSetScore // 结算阶段,广播所有人的分数,给桌面玩家或者自己头像飘分用 水果机不需要 只飘自己的分数
  33. BetCmds []Bet // 本局下注列表
  34. }
  35. type BetBase struct {
  36. BetId int
  37. Amount int
  38. IsFree bool
  39. IsRobot bool `json:"-"`
  40. }
  41. type Bet struct {
  42. BetBase
  43. UserId int
  44. Index int // 添加一个索引,用于失败撤销
  45. }
  46. type Batch_Bet struct {
  47. UserId int
  48. Bets []BetBase
  49. }
  50. type RankingUser struct {
  51. UserId int
  52. Score int
  53. }
  54. // 是否相同下注类型
  55. func (b *Bet) IsSameBet(b2 *Bet) bool {
  56. return b.BetId == b2.BetId && b.IsFree == b2.IsFree
  57. }
  58. type BetRet struct {
  59. ErrorMsg string
  60. }
  61. type Result struct {
  62. Bet
  63. WinAmount int
  64. SpinResult Fruit
  65. WinArea Fruit
  66. Tax int
  67. }
  68. type RecordInfo struct {
  69. SpinResult Fruit
  70. SerialNumber int
  71. }
  72. type UserClear struct {
  73. RoomName string
  74. UserId int
  75. }
  76. // 连胜用户和累计下注用户
  77. type ScoreUser struct {
  78. UserId int
  79. NickName string
  80. FaceId int
  81. FaceUrl string
  82. VipLevel int
  83. VipExpire int
  84. Decorations []userservices.UserDecoration
  85. IsRobot bool `json:"-"`
  86. Info []int
  87. BetAmount int
  88. }
  89. type ScoreUsers struct {
  90. //LuckyStarUsers []ScoreUser
  91. WinGoldRankingUsers []ScoreUser
  92. BetGoldRankingUsers []ScoreUser
  93. }
  94. func IsInTopN(rankList []ScoreUser, userId, n int) bool {
  95. for i, v := range rankList {
  96. if i >= n {
  97. break
  98. }
  99. if v.UserId == userId {
  100. return true
  101. }
  102. }
  103. return false
  104. }
  105. func GetRedisKey(key string) string {
  106. return fmt.Sprintf("%s:%s", GAME_NAME, key)
  107. }