gen_pool.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var GenPool = &genPoolConfig{}
  4. func init() {
  5. _allList = append(_allList, GenPool)
  6. }
  7. type (
  8. GenPoolRow struct {
  9. ID int32 `json:"ID"` // 产出池ID
  10. ItemID int32 `json:"ItemID"` // 道具ID
  11. Num int64 `json:"Num"` // 数量
  12. TimeType int32 `json:"TimeType"` // 间隔时间类型
  13. }
  14. genPoolConfig struct {
  15. baseConfig
  16. list []*GenPoolRow // all list
  17. idListMaps map[int32][]*GenPoolRow // key:id
  18. idItemIDUniMaps map[int32]map[int32]*GenPoolRow // key:id, itemID
  19. }
  20. )
  21. func (p *genPoolConfig) Name() string {
  22. return "gen_pool"
  23. }
  24. func (p *genPoolConfig) Init() {
  25. p.idListMaps = map[int32][]*GenPoolRow{}
  26. p.idItemIDUniMaps = map[int32]map[int32]*GenPoolRow{}
  27. }
  28. func (p *genPoolConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  29. if reload && p.denyLoad {
  30. return 0, nil
  31. }
  32. var list []*GenPoolRow
  33. if err := DecodeData(maps, &list); err != nil {
  34. return 0, err
  35. }
  36. p.list = list
  37. idListMaps := map[int32][]*GenPoolRow{}
  38. for _, row := range list {
  39. idListMaps[row.ID] = append(idListMaps[row.ID], row)
  40. }
  41. p.idListMaps = idListMaps
  42. idItemIDUniMaps := map[int32]map[int32]*GenPoolRow{}
  43. for _, row := range list {
  44. itemMap := idItemIDUniMaps[row.ID]
  45. if itemMap == nil {
  46. itemMap = map[int32]*GenPoolRow{}
  47. idItemIDUniMaps[row.ID] = itemMap
  48. }
  49. itemMap[row.ItemID] = row
  50. }
  51. p.idItemIDUniMaps = idItemIDUniMaps
  52. return len(list), nil
  53. }
  54. // func (p *genPoolConfig) OnAfterLoad(_ bool) {
  55. // }
  56. func (p *genPoolConfig) List() []*GenPoolRow {
  57. return p.list
  58. }
  59. func (p *genPoolConfig) ListByID(id int32) ([]*GenPoolRow, bool) {
  60. value, found := p.idListMaps[id]
  61. return value, found
  62. }
  63. func (p *genPoolConfig) ListContainID(id int32) bool {
  64. _, found := p.idListMaps[id]
  65. return found
  66. }
  67. func (p *genPoolConfig) GetByIDItemID(id int32, itemID int32) (*GenPoolRow, bool) {
  68. mapItem, found := p.idItemIDUniMaps[id]
  69. if !found {
  70. return nil, false
  71. }
  72. value, found := mapItem[itemID]
  73. return value, found
  74. }
  75. func (p *genPoolConfig) ContainIDItemID(id int32, itemID int32) bool {
  76. mapItem, found := p.idItemIDUniMaps[id]
  77. if !found {
  78. return false
  79. }
  80. _, found = mapItem[itemID]
  81. return found
  82. }