chapter.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var Chapter = &chapterConfig{}
  4. func init() {
  5. _allList = append(_allList, Chapter)
  6. }
  7. type (
  8. ChapterRow struct {
  9. ID int32 `json:"ID"` // 章节ID
  10. UnlockID int32 `json:"UnlockID"` // 前置关卡ID
  11. StartID int32 `json:"StartID"` // 开始关卡ID
  12. EndID int32 `json:"EndID"` // 结束关卡ID
  13. RewardPoolID int32 `json:"RewardPoolID"` // 奖励库ID
  14. }
  15. chapterConfig struct {
  16. baseConfig
  17. list []*ChapterRow // all list
  18. idUniMaps map[int32]*ChapterRow // key:id
  19. }
  20. )
  21. func (p *chapterConfig) Name() string {
  22. return "chapter"
  23. }
  24. func (p *chapterConfig) Init() {
  25. p.idUniMaps = map[int32]*ChapterRow{}
  26. }
  27. func (p *chapterConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  28. if reload && p.denyLoad {
  29. return 0, nil
  30. }
  31. var list []*ChapterRow
  32. if err := DecodeData(maps, &list); err != nil {
  33. return 0, err
  34. }
  35. p.list = list
  36. idUniMaps := map[int32]*ChapterRow{}
  37. for _, row := range list {
  38. idUniMaps[row.ID] = row
  39. }
  40. p.idUniMaps = idUniMaps
  41. return len(list), nil
  42. }
  43. // func (p *chapterConfig) OnAfterLoad(_ bool) {
  44. // }
  45. func (p *chapterConfig) List() []*ChapterRow {
  46. return p.list
  47. }
  48. func (p *chapterConfig) GetByID(id int32) (*ChapterRow, bool) {
  49. value, found := p.idUniMaps[id]
  50. return value, found
  51. }
  52. func (p *chapterConfig) ContainID(id int32) bool {
  53. _, found := p.idUniMaps[id]
  54. return found
  55. }