competitivewaterpool.pb.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package proto
  2. import (
  3. "context"
  4. "bet24.com/log"
  5. "bet24.com/servers/micros/common"
  6. )
  7. type Inventory_req struct {
  8. GameID int // 游戏id
  9. RoomName string // 房间名称
  10. RoomType int // 房间类型
  11. InventoryValue int // 实时库存值
  12. MinInventoryValue int // 库存取值下限
  13. MaxInventoryValue int // 库存取值上限
  14. MaxControlRate int // 控制率上限
  15. ReduceValue int // 减少值
  16. }
  17. type Inventory_resp struct {
  18. InventoryValue int // 库存值
  19. InventoryType int // 库存类型
  20. InventoryList
  21. }
  22. // 库存信息
  23. type InventoryInfo struct {
  24. GameID int // 游戏ID
  25. RoomName string // 房间名称
  26. RoomType int // 房间类型
  27. InventoryValue int // 实时库存值
  28. ControlRate float64 // 实时控制率
  29. MinInventoryValue int // 库存取值下限
  30. MaxInventoryValue int // 库存取值上限
  31. MaxControlRate int // 控制率上限
  32. }
  33. // 库存列表
  34. type InventoryList struct {
  35. Count int // 库存数
  36. List []InventoryInfo // 库存列表数据
  37. }
  38. // 获取库存类型,用于服务游戏系统机器人
  39. func GetInventoryType(gameId int, roomName string) int {
  40. xclient := getClient()
  41. args := &Inventory_req{
  42. GameID: gameId,
  43. RoomName: roomName,
  44. }
  45. reply := &Inventory_resp{}
  46. err := xclient.Call(context.Background(), "GetInventoryType", args, reply)
  47. if err != nil {
  48. log.Debug("inventory.GetInventoryType failed to call: %v", err)
  49. common.GetClientPool().RemoveClient(ServiceName)
  50. return 0
  51. }
  52. return reply.InventoryType
  53. }
  54. // 减少库存值
  55. func ReduceInventoryValue(gameId int, roomName string, reduceValue, roomType int) {
  56. xclient := getClient()
  57. args := &Inventory_req{
  58. GameID: gameId,
  59. RoomName: roomName,
  60. RoomType: roomType,
  61. ReduceValue: reduceValue,
  62. }
  63. err := xclient.Call(context.Background(), "ReduceInventoryValue", args, nil)
  64. if err != nil {
  65. log.Debug("inventory.ReduceInventoryValue failed to call: %v", err)
  66. common.GetClientPool().RemoveClient(ServiceName)
  67. }
  68. }
  69. // 后台查询获取库存列表
  70. func GetInventoryList(gameId int) InventoryList {
  71. xclient := getClient()
  72. args := &Inventory_req{
  73. GameID: gameId,
  74. }
  75. reply := &Inventory_resp{}
  76. err := xclient.Call(context.Background(), "GetInventoryList", args, reply)
  77. if err != nil {
  78. log.Debug("inventory.GetInventoryList failed to call: %v", err)
  79. common.GetClientPool().RemoveClient(ServiceName)
  80. }
  81. return reply.InventoryList
  82. }
  83. // 后台修改库存各参数数据
  84. func UpdateInventoryList(gameId int, roomName string, roomType, value, minValue, maxValue, maxRate int) InventoryList {
  85. xclient := getClient()
  86. args := &Inventory_req{
  87. GameID: gameId,
  88. RoomName: roomName,
  89. RoomType: roomType,
  90. InventoryValue: value,
  91. MinInventoryValue: minValue,
  92. MaxInventoryValue: maxValue,
  93. MaxControlRate: maxRate,
  94. }
  95. reply := &Inventory_resp{}
  96. err := xclient.Call(context.Background(), "UpdateInventoryList", args, reply)
  97. if err != nil {
  98. log.Debug("inventory.UpdateInventoryList failed to call: %v", err)
  99. common.GetClientPool().RemoveClient(ServiceName)
  100. }
  101. return reply.InventoryList
  102. }
  103. func GetInventoryValue(gameId, roomType int, roomName string) int {
  104. xclient := getClient()
  105. args := &Inventory_req{
  106. GameID: gameId,
  107. RoomType: roomType,
  108. RoomName: roomName,
  109. }
  110. reply := &Inventory_resp{}
  111. err := xclient.Call(context.Background(), "GetInventoryValue", args, reply)
  112. if err != nil {
  113. log.Debug("inventory.GetInventoryValue failed to call: %v", err)
  114. common.GetClientPool().RemoveClient(ServiceName)
  115. }
  116. return reply.InventoryValue
  117. }