chapter_level.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var ChapterLevel = &chapterLevelConfig{}
  7. func init() {
  8. _allList = append(_allList, ChapterLevel)
  9. }
  10. type (
  11. ChapterLevelRow struct {
  12. ChapterID int32 `json:"ChapterID"` // 所属章节
  13. ID int32 `json:"ID"` // 关卡ID
  14. UnlockID int32 `json:"UnlockID"` // 前置关卡ID
  15. LevelType int32 `json:"LevelType"` // 关卡类型
  16. MonsterGroupID int32 `json:"MonsterGroupID"` // 怪物组ID
  17. CostStamina types.Assets `json:"CostStamina"` // 挑战消耗精力值
  18. DayChallengeCount int32 `json:"DayChallengeCount"` // 每日可挑战次数
  19. DayCanBuyTimes int32 `json:"DayCanBuyTimes"` // 每日可购买次数
  20. Conditions types.List[int32] `json:"Conditions"` // 星级条件
  21. FixedRewards types.Assets `json:"FixedRewards"` // 固定奖励
  22. FirstReward types.Assets `json:"FirstReward"` // 首通奖励
  23. RandomRewardPools types.PairList[int32, int] `json:"RandomRewardPools"` // 随机奖励库
  24. BattleSceneID uint32 `json:"BattleSceneID"` // 战场地图ID
  25. }
  26. chapterLevelConfig struct {
  27. baseConfig
  28. list []*ChapterLevelRow // all list
  29. idUniMaps map[int32]*ChapterLevelRow // key:id
  30. chapterIDIDUniMaps map[int32]map[int32]*ChapterLevelRow // key:chapterID, id
  31. }
  32. )
  33. func (p *chapterLevelConfig) Name() string {
  34. return "chapter_level"
  35. }
  36. func (p *chapterLevelConfig) Init() {
  37. p.idUniMaps = map[int32]*ChapterLevelRow{}
  38. p.chapterIDIDUniMaps = map[int32]map[int32]*ChapterLevelRow{}
  39. }
  40. func (p *chapterLevelConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  41. if reload && p.denyLoad {
  42. return 0, nil
  43. }
  44. var list []*ChapterLevelRow
  45. if err := DecodeData(maps, &list); err != nil {
  46. return 0, err
  47. }
  48. p.list = list
  49. idUniMaps := map[int32]*ChapterLevelRow{}
  50. for _, row := range list {
  51. idUniMaps[row.ID] = row
  52. }
  53. p.idUniMaps = idUniMaps
  54. chapterIDIDUniMaps := map[int32]map[int32]*ChapterLevelRow{}
  55. for _, row := range list {
  56. itemMap := chapterIDIDUniMaps[row.ChapterID]
  57. if itemMap == nil {
  58. itemMap = map[int32]*ChapterLevelRow{}
  59. chapterIDIDUniMaps[row.ChapterID] = itemMap
  60. }
  61. itemMap[row.ID] = row
  62. }
  63. p.chapterIDIDUniMaps = chapterIDIDUniMaps
  64. return len(list), nil
  65. }
  66. // func (p *chapterLevelConfig) OnAfterLoad(_ bool) {
  67. // }
  68. func (p *chapterLevelConfig) List() []*ChapterLevelRow {
  69. return p.list
  70. }
  71. func (p *chapterLevelConfig) GetByID(id int32) (*ChapterLevelRow, bool) {
  72. value, found := p.idUniMaps[id]
  73. return value, found
  74. }
  75. func (p *chapterLevelConfig) ContainID(id int32) bool {
  76. _, found := p.idUniMaps[id]
  77. return found
  78. }
  79. func (p *chapterLevelConfig) GetByChapterIDID(chapterID int32, id int32) (*ChapterLevelRow, bool) {
  80. mapItem, found := p.chapterIDIDUniMaps[chapterID]
  81. if !found {
  82. return nil, false
  83. }
  84. value, found := mapItem[id]
  85. return value, found
  86. }
  87. func (p *chapterLevelConfig) ContainChapterIDID(chapterID int32, id int32) bool {
  88. mapItem, found := p.chapterIDIDUniMaps[chapterID]
  89. if !found {
  90. return false
  91. }
  92. _, found = mapItem[id]
  93. return found
  94. }