facility_level.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var FacilityLevel = &facilityLevelConfig{}
  7. func init() {
  8. _allList = append(_allList, FacilityLevel)
  9. }
  10. type (
  11. FacilityLevelRow struct {
  12. FacilityID int32 `json:"FacilityID"` // 建筑ID
  13. Level int32 `json:"Level"` // 等级
  14. UpgradeCost types.Assets `json:"UpgradeCost"` // 升级消耗
  15. UpgradeDuration int64 `json:"UpgradeDuration"` // 升级时间
  16. Attrs types.Attrs `json:"Attrs"` // 属性值
  17. PreFacilities types.PairList[int32, int32] `json:"PreFacilities"` // 前置建筑等级
  18. LordLevel int32 `json:"LordLevel"` // 领主等级条件
  19. }
  20. facilityLevelConfig struct {
  21. baseConfig
  22. list []*FacilityLevelRow // all list
  23. facilityIDLevelUniMaps map[int32]map[int32]*FacilityLevelRow // key:facilityID, level
  24. }
  25. )
  26. func (p *facilityLevelConfig) Name() string {
  27. return "facility_level"
  28. }
  29. func (p *facilityLevelConfig) Init() {
  30. p.facilityIDLevelUniMaps = map[int32]map[int32]*FacilityLevelRow{}
  31. }
  32. func (p *facilityLevelConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  33. if reload && p.denyLoad {
  34. return 0, nil
  35. }
  36. var list []*FacilityLevelRow
  37. if err := DecodeData(maps, &list); err != nil {
  38. return 0, err
  39. }
  40. p.list = list
  41. facilityIDLevelUniMaps := map[int32]map[int32]*FacilityLevelRow{}
  42. for _, row := range list {
  43. itemMap := facilityIDLevelUniMaps[row.FacilityID]
  44. if itemMap == nil {
  45. itemMap = map[int32]*FacilityLevelRow{}
  46. facilityIDLevelUniMaps[row.FacilityID] = itemMap
  47. }
  48. itemMap[row.Level] = row
  49. }
  50. p.facilityIDLevelUniMaps = facilityIDLevelUniMaps
  51. return len(list), nil
  52. }
  53. // func (p *facilityLevelConfig) OnAfterLoad(_ bool) {
  54. // }
  55. func (p *facilityLevelConfig) List() []*FacilityLevelRow {
  56. return p.list
  57. }
  58. func (p *facilityLevelConfig) GetByFacilityIDLevel(facilityID int32, level int32) (*FacilityLevelRow, bool) {
  59. mapItem, found := p.facilityIDLevelUniMaps[facilityID]
  60. if !found {
  61. return nil, false
  62. }
  63. value, found := mapItem[level]
  64. return value, found
  65. }
  66. func (p *facilityLevelConfig) ContainFacilityIDLevel(facilityID int32, level int32) bool {
  67. mapItem, found := p.facilityIDLevelUniMaps[facilityID]
  68. if !found {
  69. return false
  70. }
  71. _, found = mapItem[level]
  72. return found
  73. }