battlepass.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package battlepass
  2. import (
  3. "bet24.com/log"
  4. item "bet24.com/servers/micros/item_inventory/proto"
  5. )
  6. var mgr *battlepass_manager
  7. var inventory_add func(userId int, items []item.ItemPack, desc string, logType int) bool
  8. func Run(inventoryAddFunc func(userId int, items []item.ItemPack, desc string, logType int) bool) {
  9. mgr = newBattlePassManager()
  10. inventory_add = inventoryAddFunc
  11. mgr.initData()
  12. }
  13. func AddUser(userId int) {
  14. mgr.onUserEnter(userId)
  15. }
  16. func RemoveUser(userId int) {
  17. mgr.onUserExit(userId)
  18. }
  19. func BuyGrowthPack(userId int, productId string) (int, string) {
  20. return mgr.buyGrowthPack(userId, productId)
  21. }
  22. func GetBattlePassPacks() []GrowthPack {
  23. return mgr.getGrowthPacks()
  24. }
  25. func GetUserBattlePass(userId int) []*UserGrowthTerm {
  26. return mgr.getUserGrowthTerms(userId)
  27. }
  28. func UserAwardBattlePass(userId int, growthPackId, index int) (bool, string) {
  29. return mgr.userAwardTerm(userId, growthPackId, index)
  30. }
  31. func Dump(param1, param2 string) {
  32. switch param1 {
  33. case "sys":
  34. mgr.dumpSys(param2)
  35. case "user":
  36. mgr.dumpUser(param2)
  37. default:
  38. log.Debug("battlepass.Dump unhandled %s:%s", param1, param2)
  39. }
  40. }
  41. func AddUserExp(userId int, exp int) {
  42. mgr.addExp(userId, exp)
  43. }