quest_achieve_pool.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var QuestAchievePool = &questAchievePoolConfig{}
  7. func init() {
  8. _allList = append(_allList, QuestAchievePool)
  9. }
  10. type (
  11. QuestAchievePoolRow struct {
  12. PoolID int32 `json:"PoolID"` // 库ID
  13. ChapterID int32 `json:"ChapterID"` // 章节ID
  14. QuestGroupIDs types.List[int32] `json:"QuestGroupIDs"` // 任务组ID列表
  15. }
  16. questAchievePoolConfig struct {
  17. baseConfig
  18. list []*QuestAchievePoolRow // all list
  19. poolIDListMaps map[int32][]*QuestAchievePoolRow // key:poolID
  20. poolIDChapterIDUniMaps map[int32]map[int32]*QuestAchievePoolRow // key:poolID, chapterID
  21. }
  22. )
  23. func (p *questAchievePoolConfig) Name() string {
  24. return "quest_achieve_pool"
  25. }
  26. func (p *questAchievePoolConfig) Init() {
  27. p.poolIDListMaps = map[int32][]*QuestAchievePoolRow{}
  28. p.poolIDChapterIDUniMaps = map[int32]map[int32]*QuestAchievePoolRow{}
  29. }
  30. func (p *questAchievePoolConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  31. if reload && p.denyLoad {
  32. return 0, nil
  33. }
  34. var list []*QuestAchievePoolRow
  35. if err := DecodeData(maps, &list); err != nil {
  36. return 0, err
  37. }
  38. p.list = list
  39. poolIDListMaps := map[int32][]*QuestAchievePoolRow{}
  40. for _, row := range list {
  41. poolIDListMaps[row.PoolID] = append(poolIDListMaps[row.PoolID], row)
  42. }
  43. p.poolIDListMaps = poolIDListMaps
  44. poolIDChapterIDUniMaps := map[int32]map[int32]*QuestAchievePoolRow{}
  45. for _, row := range list {
  46. itemMap := poolIDChapterIDUniMaps[row.PoolID]
  47. if itemMap == nil {
  48. itemMap = map[int32]*QuestAchievePoolRow{}
  49. poolIDChapterIDUniMaps[row.PoolID] = itemMap
  50. }
  51. itemMap[row.ChapterID] = row
  52. }
  53. p.poolIDChapterIDUniMaps = poolIDChapterIDUniMaps
  54. return len(list), nil
  55. }
  56. // func (p *questAchievePoolConfig) OnAfterLoad(_ bool) {
  57. // }
  58. func (p *questAchievePoolConfig) List() []*QuestAchievePoolRow {
  59. return p.list
  60. }
  61. func (p *questAchievePoolConfig) ListByPoolID(poolID int32) ([]*QuestAchievePoolRow, bool) {
  62. value, found := p.poolIDListMaps[poolID]
  63. return value, found
  64. }
  65. func (p *questAchievePoolConfig) ListContainPoolID(poolID int32) bool {
  66. _, found := p.poolIDListMaps[poolID]
  67. return found
  68. }
  69. func (p *questAchievePoolConfig) GetByPoolIDChapterID(poolID int32, chapterID int32) (*QuestAchievePoolRow, bool) {
  70. mapItem, found := p.poolIDChapterIDUniMaps[poolID]
  71. if !found {
  72. return nil, false
  73. }
  74. value, found := mapItem[chapterID]
  75. return value, found
  76. }
  77. func (p *questAchievePoolConfig) ContainPoolIDChapterID(poolID int32, chapterID int32) bool {
  78. mapItem, found := p.poolIDChapterIDUniMaps[poolID]
  79. if !found {
  80. return false
  81. }
  82. _, found = mapItem[chapterID]
  83. return found
  84. }