shop_card.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var ShopCard = &shopCardConfig{}
  7. func init() {
  8. _allList = append(_allList, ShopCard)
  9. }
  10. type (
  11. ShopCardRow struct {
  12. ID int32 `json:"ID"` // ID
  13. ChargeRewards types.Assets `json:"ChargeRewards"` // 立即获得奖励
  14. Day int32 `json:"Day"` // 持续天数
  15. DayRewards types.Assets `json:"DayRewards"` // 持续奖励
  16. DayLimit int32 `json:"DayLimit"` // 日期上限
  17. }
  18. shopCardConfig struct {
  19. baseConfig
  20. list []*ShopCardRow // all list
  21. idUniMaps map[int32]*ShopCardRow // key:id
  22. }
  23. )
  24. func (p *shopCardConfig) Name() string {
  25. return "shop_card"
  26. }
  27. func (p *shopCardConfig) Init() {
  28. p.idUniMaps = map[int32]*ShopCardRow{}
  29. }
  30. func (p *shopCardConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  31. if reload && p.denyLoad {
  32. return 0, nil
  33. }
  34. var list []*ShopCardRow
  35. if err := DecodeData(maps, &list); err != nil {
  36. return 0, err
  37. }
  38. p.list = list
  39. idUniMaps := map[int32]*ShopCardRow{}
  40. for _, row := range list {
  41. idUniMaps[row.ID] = row
  42. }
  43. p.idUniMaps = idUniMaps
  44. return len(list), nil
  45. }
  46. // func (p *shopCardConfig) OnAfterLoad(_ bool) {
  47. // }
  48. func (p *shopCardConfig) List() []*ShopCardRow {
  49. return p.list
  50. }
  51. func (p *shopCardConfig) GetByID(id int32) (*ShopCardRow, bool) {
  52. value, found := p.idUniMaps[id]
  53. return value, found
  54. }
  55. func (p *shopCardConfig) ContainID(id int32) bool {
  56. _, found := p.idUniMaps[id]
  57. return found
  58. }