| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- // Code generated by excel export. DO NOT EDIT.
- package data
- var MonsterPool = &monsterPoolConfig{}
- func init() {
- _allList = append(_allList, MonsterPool)
- }
- type (
- MonsterPoolRow struct {
- PoolID int32 `json:"PoolID"` // 怪物池ID
- GroupID int32 `json:"GroupID"` // 怪物组ID
- Weight int32 `json:"Weight"` // 权重
- }
- monsterPoolConfig struct {
- baseConfig
- list []*MonsterPoolRow // all list
- poolIDListMaps map[int32][]*MonsterPoolRow // key:poolID
- poolIDGroupIDUniMaps map[int32]map[int32]*MonsterPoolRow // key:poolID, groupID
- }
- )
- func (p *monsterPoolConfig) Name() string {
- return "monster_pool"
- }
- func (p *monsterPoolConfig) Init() {
- p.poolIDListMaps = map[int32][]*MonsterPoolRow{}
- p.poolIDGroupIDUniMaps = map[int32]map[int32]*MonsterPoolRow{}
- }
- func (p *monsterPoolConfig) OnLoad(maps interface{}, reload bool) (int, error) {
- if reload && p.denyLoad {
- return 0, nil
- }
- var list []*MonsterPoolRow
- if err := DecodeData(maps, &list); err != nil {
- return 0, err
- }
- p.list = list
- poolIDListMaps := map[int32][]*MonsterPoolRow{}
- for _, row := range list {
- poolIDListMaps[row.PoolID] = append(poolIDListMaps[row.PoolID], row)
- }
- p.poolIDListMaps = poolIDListMaps
- poolIDGroupIDUniMaps := map[int32]map[int32]*MonsterPoolRow{}
- for _, row := range list {
- itemMap := poolIDGroupIDUniMaps[row.PoolID]
- if itemMap == nil {
- itemMap = map[int32]*MonsterPoolRow{}
- poolIDGroupIDUniMaps[row.PoolID] = itemMap
- }
- itemMap[row.GroupID] = row
- }
- p.poolIDGroupIDUniMaps = poolIDGroupIDUniMaps
- return len(list), nil
- }
- // func (p *monsterPoolConfig) OnAfterLoad(_ bool) {
- // }
- func (p *monsterPoolConfig) List() []*MonsterPoolRow {
- return p.list
- }
- func (p *monsterPoolConfig) ListByPoolID(poolID int32) ([]*MonsterPoolRow, bool) {
- value, found := p.poolIDListMaps[poolID]
- return value, found
- }
- func (p *monsterPoolConfig) ListContainPoolID(poolID int32) bool {
- _, found := p.poolIDListMaps[poolID]
- return found
- }
- func (p *monsterPoolConfig) GetByPoolIDGroupID(poolID int32, groupID int32) (*MonsterPoolRow, bool) {
- mapItem, found := p.poolIDGroupIDUniMaps[poolID]
- if !found {
- return nil, false
- }
- value, found := mapItem[groupID]
- return value, found
- }
- func (p *monsterPoolConfig) ContainPoolIDGroupID(poolID int32, groupID int32) bool {
- mapItem, found := p.poolIDGroupIDUniMaps[poolID]
- if !found {
- return false
- }
- _, found = mapItem[groupID]
- return found
- }
|