growthpack.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package giftpack
  2. import (
  3. _ "bet24.com/log"
  4. item "bet24.com/servers/micros/item_inventory/proto"
  5. )
  6. const (
  7. GrowthTermStatus_none = iota // 没有
  8. GrowthTermStatus_complete // 可领取
  9. GrowthTermStatus_awarded // 已领取
  10. )
  11. type GrowthPack struct {
  12. Id int // 礼包ID
  13. ProductId string // 商城产品ID
  14. Name string // 名称
  15. Price int // 价格
  16. Terms []GrowthTerm // 礼包列表
  17. }
  18. type GrowthTerm struct {
  19. TermIndex int // index
  20. Name string // 名称
  21. Bullet int // 解锁子弹
  22. Items []item.ItemPack // 礼包内容
  23. }
  24. type UserGrowthTerm struct {
  25. UserId int // 用户ID,客户端不发
  26. GrowthPackId int // 礼包ID
  27. TermIndex int // index
  28. Bullet int // 目标炮台等级
  29. Status int // 目前状态
  30. }
  31. var gmgr *growthpackmgr
  32. func AddUser(userId int) {
  33. gmgr.onUserEnter(userId)
  34. }
  35. func RemoveUser(userId int) {
  36. gmgr.onUserExit(userId)
  37. }
  38. func BuyGrowthPack(userId int, productId string) (int, string, []item.ItemPack) {
  39. return gmgr.buyGrowthPack(userId, productId)
  40. }
  41. func GetGrowthPacks() []*GrowthPack {
  42. return gmgr.getGrowthPacks()
  43. }
  44. func GetUserGrowthTerms(userId int) []*UserGrowthTerm {
  45. return gmgr.getUserGrowthTerms(userId)
  46. }
  47. func UserAwardTerm(userId int, growthPackId, index int) (bool, string) {
  48. return gmgr.userAwardTerm(userId, growthPackId, index)
  49. }