// Code generated by excel export. DO NOT EDIT. package data import ( "f1-game/internal/types" ) var MiniGame = &miniGameConfig{} func init() { _allList = append(_allList, MiniGame) } type ( MiniGameRow struct { GameID int32 `json:"GameID"` // 游戏ID LevelID int32 `json:"LevelID"` // 关卡ID NextLevelID int32 `json:"NextLevelID"` // 下一关卡ID Name int32 `json:"Name"` // 关卡名称 Headlcon string `json:"Headlcon"` // 关卡怪物头像 ChapterUnlockLevelID int32 `json:"ChapterUnlockLevelID"` // 探险解锁关卡ID LevelType int32 `json:"LevelType"` // 关卡类型 Reward types.Assets `json:"Reward"` // 奖励 } miniGameConfig struct { baseConfig list []*MiniGameRow // all list gameIDLevelIDUniMaps map[int32]map[int32]*MiniGameRow // key:gameID, levelID } ) func (p *miniGameConfig) Name() string { return "mini_game" } func (p *miniGameConfig) Init() { p.gameIDLevelIDUniMaps = map[int32]map[int32]*MiniGameRow{} } func (p *miniGameConfig) OnLoad(maps interface{}, reload bool) (int, error) { if reload && p.denyLoad { return 0, nil } var list []*MiniGameRow if err := DecodeData(maps, &list); err != nil { return 0, err } p.list = list gameIDLevelIDUniMaps := map[int32]map[int32]*MiniGameRow{} for _, row := range list { itemMap := gameIDLevelIDUniMaps[row.GameID] if itemMap == nil { itemMap = map[int32]*MiniGameRow{} gameIDLevelIDUniMaps[row.GameID] = itemMap } itemMap[row.LevelID] = row } p.gameIDLevelIDUniMaps = gameIDLevelIDUniMaps return len(list), nil } // func (p *miniGameConfig) OnAfterLoad(_ bool) { // } func (p *miniGameConfig) List() []*MiniGameRow { return p.list } func (p *miniGameConfig) GetByGameIDLevelID(gameID int32, levelID int32) (*MiniGameRow, bool) { mapItem, found := p.gameIDLevelIDUniMaps[gameID] if !found { return nil, false } value, found := mapItem[levelID] return value, found } func (p *miniGameConfig) ContainGameIDLevelID(gameID int32, levelID int32) bool { mapItem, found := p.gameIDLevelIDUniMaps[gameID] if !found { return false } _, found = mapItem[levelID] return found }