// Code generated by excel export. DO NOT EDIT. package data import ( "f1-game/internal/types" ) var ChapterReward = &chapterRewardConfig{} func init() { _allList = append(_allList, ChapterReward) } type ( ChapterRewardRow struct { ID int32 `json:"ID"` // 奖励库ID StarNum int32 `json:"StarNum"` // 所需星数 Reward types.Assets `json:"Reward"` // 奖励 } chapterRewardConfig struct { baseConfig list []*ChapterRewardRow // all list idListMaps map[int32][]*ChapterRewardRow // key:id idStarNumUniMaps map[int32]map[int32]*ChapterRewardRow // key:id, starNum } ) func (p *chapterRewardConfig) Name() string { return "chapter_reward" } func (p *chapterRewardConfig) Init() { p.idListMaps = map[int32][]*ChapterRewardRow{} p.idStarNumUniMaps = map[int32]map[int32]*ChapterRewardRow{} } func (p *chapterRewardConfig) OnLoad(maps interface{}, reload bool) (int, error) { if reload && p.denyLoad { return 0, nil } var list []*ChapterRewardRow if err := DecodeData(maps, &list); err != nil { return 0, err } p.list = list idListMaps := map[int32][]*ChapterRewardRow{} for _, row := range list { idListMaps[row.ID] = append(idListMaps[row.ID], row) } p.idListMaps = idListMaps idStarNumUniMaps := map[int32]map[int32]*ChapterRewardRow{} for _, row := range list { itemMap := idStarNumUniMaps[row.ID] if itemMap == nil { itemMap = map[int32]*ChapterRewardRow{} idStarNumUniMaps[row.ID] = itemMap } itemMap[row.StarNum] = row } p.idStarNumUniMaps = idStarNumUniMaps return len(list), nil } // func (p *chapterRewardConfig) OnAfterLoad(_ bool) { // } func (p *chapterRewardConfig) List() []*ChapterRewardRow { return p.list } func (p *chapterRewardConfig) ListByID(id int32) ([]*ChapterRewardRow, bool) { value, found := p.idListMaps[id] return value, found } func (p *chapterRewardConfig) ListContainID(id int32) bool { _, found := p.idListMaps[id] return found } func (p *chapterRewardConfig) GetByIDStarNum(id int32, starNum int32) (*ChapterRewardRow, bool) { mapItem, found := p.idStarNumUniMaps[id] if !found { return nil, false } value, found := mapItem[starNum] return value, found } func (p *chapterRewardConfig) ContainIDStarNum(id int32, starNum int32) bool { mapItem, found := p.idStarNumUniMaps[id] if !found { return false } _, found = mapItem[starNum] return found }