prizewheel.go 797 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package prizewheel
  2. import (
  3. item "bet24.com/servers/micros/item_inventory/proto"
  4. )
  5. type Prize struct {
  6. Id int // 客户端排序用
  7. Chance int `json:"-"` // 概率 万分之
  8. Items []item.ItemPack
  9. }
  10. var mgr *prizewheelmgr
  11. func Run() {
  12. mgr = newPrizeWheelManager()
  13. }
  14. func Wheel(userId, count int, nickName, ipAddress string) ([]*Prize, string) {
  15. return mgr.wheel(userId, count, nickName, ipAddress)
  16. }
  17. func Dump(param1, param2 string) {
  18. mgr.dump(param1, param2)
  19. }
  20. func GetPrizes() []*Prize {
  21. return mgr.getPrizes()
  22. }
  23. func GetWheelTimes(userId int) (int, int, int) {
  24. return mgr.getWheelTimes(userId)
  25. }
  26. func GetRecord() []*userPrizeRecord {
  27. return mgr.getRecord()
  28. }
  29. func AddUser(userId int) {
  30. mgr.onUserEnter(userId)
  31. }
  32. func RemoveUser(userId int) {
  33. mgr.onUserExit(userId)
  34. }