signinwheel.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package signinwheel
  2. import (
  3. "bet24.com/log"
  4. item "bet24.com/servers/micros/item_inventory/proto"
  5. )
  6. var mgr *signinwheelmgr
  7. type SigninWheelResult struct {
  8. Base int // 基础数值
  9. Multiple int // 倍率
  10. ItemId int
  11. Items []item.ItemPack
  12. }
  13. type SigninWheelHistory struct {
  14. UserId int
  15. NickName string
  16. FaceId int
  17. FaceUrl string
  18. SigninWheelResult
  19. }
  20. type config_param struct {
  21. Param int // 参数
  22. Chance int `json:",omitempty"` // 概率,客户端看不到
  23. ItemId int // 物品Id,默认是金币
  24. Count int // 物品数量,默认是金币
  25. }
  26. type SigninWheelConfig struct {
  27. Cost int
  28. totalBaseChance int
  29. totalMultipleChance int
  30. Base []config_param // 基础配置
  31. Multiple []config_param // 倍数配置
  32. }
  33. type UserSiginWheelInfo struct {
  34. CanSignin bool // 我是否可以签到
  35. MyPlayTimes int //我的播放次数
  36. SysPlayTimes int //系统播放次数
  37. SigninWheelConfig // 签到配置信息
  38. }
  39. func Run() {
  40. mgr = newSigninWheelManager()
  41. log.Debug("signinwheel runing")
  42. }
  43. func DoSignin(userId int, ipAddress string, userGold int) (SigninWheelResult, int) {
  44. return mgr.doSignin(userId, ipAddress, userGold)
  45. }
  46. func GetHistory() []SigninWheelHistory {
  47. return mgr.getHistory()
  48. }
  49. func GetSigninWheelInfo(userId int) UserSiginWheelInfo {
  50. return mgr.getSigninWheelInfo(userId)
  51. }
  52. func CheckSignTip(userId int) bool {
  53. return mgr.canSignin(userId, "", true)
  54. }
  55. func Dump(param1, param2 string) {
  56. switch param1 {
  57. case "sys":
  58. mgr.dumpSys(param2)
  59. case "user":
  60. mgr.dumpUser(param2)
  61. case "history":
  62. mgr.dumpHistory()
  63. case "test":
  64. mgr.test(param2)
  65. case "testlevel":
  66. mgr.testLevel(param2)
  67. default:
  68. log.Debug("signinwheel.Dump unhandled %s:%s", param1, param2)
  69. }
  70. }