shop.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var Shop = &shopConfig{}
  7. func init() {
  8. _allList = append(_allList, Shop)
  9. }
  10. type (
  11. ShopRow struct {
  12. ShopID int32 `json:"ShopID"` // 商店ID
  13. ShopType int32 `json:"ShopType"` // 商店类型
  14. ResetType int32 `json:"ResetType"` // 重置类型
  15. UnlockType int32 `json:"UnlockType"` // 解锁类型
  16. UnlockValue int32 `json:"UnlockValue"` // 解锁值
  17. ShopPools types.PairList[int32, int32] `json:"ShopPools"` // 商品库
  18. }
  19. shopConfig struct {
  20. baseConfig
  21. list []*ShopRow // all list
  22. shopIDUniMaps map[int32]*ShopRow // key:shopID
  23. }
  24. )
  25. func (p *shopConfig) Name() string {
  26. return "shop"
  27. }
  28. func (p *shopConfig) Init() {
  29. p.shopIDUniMaps = map[int32]*ShopRow{}
  30. }
  31. func (p *shopConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  32. if reload && p.denyLoad {
  33. return 0, nil
  34. }
  35. var list []*ShopRow
  36. if err := DecodeData(maps, &list); err != nil {
  37. return 0, err
  38. }
  39. p.list = list
  40. shopIDUniMaps := map[int32]*ShopRow{}
  41. for _, row := range list {
  42. shopIDUniMaps[row.ShopID] = row
  43. }
  44. p.shopIDUniMaps = shopIDUniMaps
  45. return len(list), nil
  46. }
  47. // func (p *shopConfig) OnAfterLoad(_ bool) {
  48. // }
  49. func (p *shopConfig) List() []*ShopRow {
  50. return p.list
  51. }
  52. func (p *shopConfig) GetByShopID(shopID int32) (*ShopRow, bool) {
  53. value, found := p.shopIDUniMaps[shopID]
  54. return value, found
  55. }
  56. func (p *shopConfig) ContainShopID(shopID int32) bool {
  57. _, found := p.shopIDUniMaps[shopID]
  58. return found
  59. }