vip.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var Vip = &vipConfig{}
  7. func init() {
  8. _allList = append(_allList, Vip)
  9. }
  10. type (
  11. VipRow struct {
  12. Level int32 `json:"Level"` // 等级
  13. Exp int64 `json:"Exp"` // 升至下级所需点数
  14. DailyBox types.Assets `json:"DailyBox"` // 每日宝箱
  15. SpecialBox types.Assets `json:"SpecialBox"` // 专属宝箱
  16. SpecialBoxChargeID int32 `json:"SpecialBoxChargeID"` // 专属宝箱充值ID
  17. Attrs types.Attrs `json:"Attrs"` // 特权加成
  18. }
  19. vipConfig struct {
  20. baseConfig
  21. list []*VipRow // all list
  22. levelUniMaps map[int32]*VipRow // key:level
  23. specialBoxChargeIDUniMaps map[int32]*VipRow // key:specialBoxChargeID
  24. }
  25. )
  26. func (p *vipConfig) Name() string {
  27. return "vip"
  28. }
  29. func (p *vipConfig) Init() {
  30. p.levelUniMaps = map[int32]*VipRow{}
  31. p.specialBoxChargeIDUniMaps = map[int32]*VipRow{}
  32. }
  33. func (p *vipConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  34. if reload && p.denyLoad {
  35. return 0, nil
  36. }
  37. var list []*VipRow
  38. if err := DecodeData(maps, &list); err != nil {
  39. return 0, err
  40. }
  41. p.list = list
  42. levelUniMaps := map[int32]*VipRow{}
  43. for _, row := range list {
  44. levelUniMaps[row.Level] = row
  45. }
  46. p.levelUniMaps = levelUniMaps
  47. specialBoxChargeIDUniMaps := map[int32]*VipRow{}
  48. for _, row := range list {
  49. specialBoxChargeIDUniMaps[row.SpecialBoxChargeID] = row
  50. }
  51. p.specialBoxChargeIDUniMaps = specialBoxChargeIDUniMaps
  52. return len(list), nil
  53. }
  54. // func (p *vipConfig) OnAfterLoad(_ bool) {
  55. // }
  56. func (p *vipConfig) List() []*VipRow {
  57. return p.list
  58. }
  59. func (p *vipConfig) GetByLevel(level int32) (*VipRow, bool) {
  60. value, found := p.levelUniMaps[level]
  61. return value, found
  62. }
  63. func (p *vipConfig) ContainLevel(level int32) bool {
  64. _, found := p.levelUniMaps[level]
  65. return found
  66. }
  67. func (p *vipConfig) GetBySpecialBoxChargeID(specialBoxChargeID int32) (*VipRow, bool) {
  68. value, found := p.specialBoxChargeIDUniMaps[specialBoxChargeID]
  69. return value, found
  70. }
  71. func (p *vipConfig) ContainSpecialBoxChargeID(specialBoxChargeID int32) bool {
  72. _, found := p.specialBoxChargeIDUniMaps[specialBoxChargeID]
  73. return found
  74. }