monster_group.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var MonsterGroup = &monsterGroupConfig{}
  4. func init() {
  5. _allList = append(_allList, MonsterGroup)
  6. }
  7. type (
  8. MonsterGroupRow struct {
  9. ID int32 `json:"ID"` // ID
  10. LineupIndex int32 `json:"LineupIndex"` // 阵容站位
  11. MonsterID int32 `json:"MonsterID"` // 怪物ID
  12. TroopTypeID int32 `json:"TroopTypeID"` // 兵种ID
  13. Troop int32 `json:"Troop"` // 兵力
  14. }
  15. monsterGroupConfig struct {
  16. baseConfig
  17. list []*MonsterGroupRow // all list
  18. idLineupIndexUniMaps map[int32]map[int32]*MonsterGroupRow // key:id, lineupIndex
  19. }
  20. )
  21. func (p *monsterGroupConfig) Name() string {
  22. return "monster_group"
  23. }
  24. func (p *monsterGroupConfig) Init() {
  25. p.idLineupIndexUniMaps = map[int32]map[int32]*MonsterGroupRow{}
  26. }
  27. func (p *monsterGroupConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  28. if reload && p.denyLoad {
  29. return 0, nil
  30. }
  31. var list []*MonsterGroupRow
  32. if err := DecodeData(maps, &list); err != nil {
  33. return 0, err
  34. }
  35. p.list = list
  36. idLineupIndexUniMaps := map[int32]map[int32]*MonsterGroupRow{}
  37. for _, row := range list {
  38. itemMap := idLineupIndexUniMaps[row.ID]
  39. if itemMap == nil {
  40. itemMap = map[int32]*MonsterGroupRow{}
  41. idLineupIndexUniMaps[row.ID] = itemMap
  42. }
  43. itemMap[row.LineupIndex] = row
  44. }
  45. p.idLineupIndexUniMaps = idLineupIndexUniMaps
  46. return len(list), nil
  47. }
  48. // func (p *monsterGroupConfig) OnAfterLoad(_ bool) {
  49. // }
  50. func (p *monsterGroupConfig) List() []*MonsterGroupRow {
  51. return p.list
  52. }
  53. func (p *monsterGroupConfig) GetByIDLineupIndex(id int32, lineupIndex int32) (*MonsterGroupRow, bool) {
  54. mapItem, found := p.idLineupIndexUniMaps[id]
  55. if !found {
  56. return nil, false
  57. }
  58. value, found := mapItem[lineupIndex]
  59. return value, found
  60. }
  61. func (p *monsterGroupConfig) ContainIDLineupIndex(id int32, lineupIndex int32) bool {
  62. mapItem, found := p.idLineupIndexUniMaps[id]
  63. if !found {
  64. return false
  65. }
  66. _, found = mapItem[lineupIndex]
  67. return found
  68. }