individualwaterpool.pb.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. package proto
  2. import (
  3. "context"
  4. "bet24.com/log"
  5. "bet24.com/servers/micros/common"
  6. )
  7. type IndividualWaterPool_req struct {
  8. UserId int
  9. GameId int
  10. GameType int
  11. Amount int
  12. GenType string
  13. BaseScore int
  14. Gold int
  15. IsMatch bool
  16. RoomType int
  17. RoomID int
  18. Param int
  19. }
  20. type IndividualWaterPoolGrantRecord_req struct {
  21. UserID int
  22. BeginTime int
  23. EndTime int
  24. PageIndex int
  25. PageSize int
  26. }
  27. type IndividualWaterPool_resp struct {
  28. PoolType int
  29. PoolValue int
  30. PoolProb int
  31. GrantRecords
  32. }
  33. // 个人奖池生成方式,目前其他类型还没有确定
  34. const (
  35. GenerationType_ByHand = iota // 手动生成
  36. )
  37. const (
  38. GameType_Normal = 100 // 普通模式
  39. GameType_Doubling = 101 // 加倍模式
  40. GameType_Correct = 102 // 纠错模式
  41. )
  42. const (
  43. RoomType_Normal = 1 // 普通
  44. RoomType_Doubling = 2 // 加倍
  45. RoomType_Quick = 3 // 快速
  46. RoomType_Ladder = 4 // 排位
  47. RoomType_Hundred = 5 // 百人
  48. RoomType_Slot = 6 // slot
  49. )
  50. // 生成类型
  51. const (
  52. GenType_ByHand = "GenType_ByHand" // 手动生成
  53. GenType_NewUserSigned = "GenType_NewUserSigned" // 新用户注册
  54. )
  55. // 玩家个人奖池信息
  56. type UserWaterPoolInfo struct {
  57. UserID int // 用户ID
  58. PoolType int // 调控模式
  59. PoolValue int // 奖池数据
  60. }
  61. type UserWaterPoolInfoGrantRecord struct {
  62. Rid int
  63. UserID int
  64. NickName string
  65. PoolValue int
  66. WantValue int
  67. GenType string
  68. RoomType int
  69. RoomName string
  70. Crdate string
  71. }
  72. type GrantRecords struct {
  73. RecordCount int // 记录数
  74. List []UserWaterPoolInfoGrantRecord // 返回的数据
  75. }
  76. // 用户登录,创建用户信息
  77. func AddUser(userId int) {
  78. xclient := getClient()
  79. args := &IndividualWaterPool_req{
  80. UserId: userId,
  81. }
  82. err := xclient.Call(context.Background(), "AddUser", args, nil)
  83. if err != nil {
  84. log.Debug("individualWaterPool.AddUser failed to call: %v", err)
  85. common.GetClientPool().RemoveClient(ServiceName)
  86. }
  87. }
  88. // 用户离线,删除用户数据
  89. func RemoveUser(userId int) {
  90. xclient := getClient()
  91. args := &IndividualWaterPool_req{
  92. UserId: userId,
  93. }
  94. err := xclient.Call(context.Background(), "RemoveUser", args, nil)
  95. if err != nil {
  96. log.Debug("individualWaterPool.RemoveUser failed to call: %v", err)
  97. common.GetClientPool().RemoveClient(ServiceName)
  98. }
  99. }
  100. // 获取个人奖池类型,是正向还是负向的体验
  101. func GetUserPoolType(userId, gameId, gameType, baseScore, gold int, isMatch bool, param ...int) (int, int) {
  102. xclient := getClient()
  103. value := 0
  104. if len(param) != 0 {
  105. value = param[0]
  106. }
  107. args := &IndividualWaterPool_req{
  108. UserId: userId,
  109. GameId: gameId,
  110. GameType: gameType,
  111. BaseScore: baseScore,
  112. Gold: gold,
  113. IsMatch: isMatch,
  114. Param: value,
  115. }
  116. reply := &IndividualWaterPool_resp{}
  117. err := xclient.Call(context.Background(), "GetUserPoolType", args, reply)
  118. if err != nil {
  119. log.Debug("individualWaterPool.GetUserPoolType failed to call: %v", err)
  120. common.GetClientPool().RemoveClient(ServiceName)
  121. return 0, 0
  122. }
  123. return reply.PoolType, reply.PoolProb
  124. }
  125. // 给玩家发放奖池
  126. func GrantUserNewWaterPool(userId, value int, genType string) {
  127. xclient := getClient()
  128. args := &IndividualWaterPool_req{
  129. UserId: userId,
  130. Amount: value,
  131. GenType: genType,
  132. }
  133. err := xclient.Call(context.Background(), "GrantUserNewWaterPool", args, nil)
  134. if err != nil {
  135. log.Debug("individualWaterPool.GrantUserNewWaterPool failed to call: %v", err)
  136. common.GetClientPool().RemoveClient(ServiceName)
  137. }
  138. }
  139. // 玩家游戏后更新玩家奖池,供游戏内调用
  140. func UpdataUserWaterPool(userId, amount int, genType string, roomType int, roomID int) {
  141. xclient := getClient()
  142. args := &IndividualWaterPool_req{
  143. UserId: userId,
  144. Amount: amount,
  145. GenType: genType,
  146. RoomType: roomType,
  147. RoomID: roomID,
  148. }
  149. err := xclient.Call(context.Background(), "UpdataUserWaterPool", args, nil)
  150. if err != nil {
  151. log.Debug("individualWaterPool.UpdataUserWaterPool failed to call: %v", err)
  152. common.GetClientPool().RemoveClient(ServiceName)
  153. }
  154. }
  155. // 获取玩家奖池数据,数据库查询使用
  156. func GetUserWaterPool(userId int) int {
  157. xclient := getClient()
  158. args := &IndividualWaterPool_req{
  159. UserId: userId,
  160. }
  161. reply := &IndividualWaterPool_resp{}
  162. err := xclient.Call(context.Background(), "GetUserWaterPool", args, reply)
  163. if err != nil {
  164. log.Debug("individualWaterPool.GetUserWaterPool failed to call: %v", err)
  165. common.GetClientPool().RemoveClient(ServiceName)
  166. }
  167. return reply.PoolValue
  168. }
  169. func GetUserWaterPoolGrantRecords(userId, beginTime, endTime, pageIndex, pageSize int) GrantRecords {
  170. xclient := getClient()
  171. args := &IndividualWaterPoolGrantRecord_req{
  172. UserID: userId,
  173. BeginTime: beginTime,
  174. EndTime: endTime,
  175. PageIndex: pageIndex,
  176. PageSize: pageSize,
  177. }
  178. reply := &IndividualWaterPool_resp{}
  179. err := xclient.Call(context.Background(), "GetUserWaterPoolGrantRecords", args, reply)
  180. if err != nil {
  181. log.Debug("individualWaterPool.GetUserWaterPoolGrantRecords failed to call: %v", err)
  182. common.GetClientPool().RemoveClient(ServiceName)
  183. }
  184. return reply.GrantRecords
  185. }