map_build_upgrade.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var MapBuildUpgrade = &mapBuildUpgradeConfig{}
  7. func init() {
  8. _allList = append(_allList, MapBuildUpgrade)
  9. }
  10. type (
  11. MapBuildUpgradeRow struct {
  12. ConfigID int32 `json:"ConfigID"` // 建筑配置ID
  13. Level int32 `json:"Level"` // 等级
  14. UpgradeCost types.Assets `json:"UpgradeCost"` // 升级消耗
  15. UpgradeTime int64 `json:"UpgradeTime"` // 升级时间
  16. Durability int32 `json:"Durability"` // 耐久
  17. ViewRange int32 `json:"ViewRange"` // 视野范围
  18. }
  19. mapBuildUpgradeConfig struct {
  20. baseConfig
  21. list []*MapBuildUpgradeRow // all list
  22. configIDListMaps map[int32][]*MapBuildUpgradeRow // key:configID
  23. configIDLevelUniMaps map[int32]map[int32]*MapBuildUpgradeRow // key:configID, level
  24. }
  25. )
  26. func (p *mapBuildUpgradeConfig) Name() string {
  27. return "map_build_upgrade"
  28. }
  29. func (p *mapBuildUpgradeConfig) Init() {
  30. p.configIDListMaps = map[int32][]*MapBuildUpgradeRow{}
  31. p.configIDLevelUniMaps = map[int32]map[int32]*MapBuildUpgradeRow{}
  32. }
  33. func (p *mapBuildUpgradeConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  34. if reload && p.denyLoad {
  35. return 0, nil
  36. }
  37. var list []*MapBuildUpgradeRow
  38. if err := DecodeData(maps, &list); err != nil {
  39. return 0, err
  40. }
  41. p.list = list
  42. configIDListMaps := map[int32][]*MapBuildUpgradeRow{}
  43. for _, row := range list {
  44. configIDListMaps[row.ConfigID] = append(configIDListMaps[row.ConfigID], row)
  45. }
  46. p.configIDListMaps = configIDListMaps
  47. configIDLevelUniMaps := map[int32]map[int32]*MapBuildUpgradeRow{}
  48. for _, row := range list {
  49. itemMap := configIDLevelUniMaps[row.ConfigID]
  50. if itemMap == nil {
  51. itemMap = map[int32]*MapBuildUpgradeRow{}
  52. configIDLevelUniMaps[row.ConfigID] = itemMap
  53. }
  54. itemMap[row.Level] = row
  55. }
  56. p.configIDLevelUniMaps = configIDLevelUniMaps
  57. return len(list), nil
  58. }
  59. // func (p *mapBuildUpgradeConfig) OnAfterLoad(_ bool) {
  60. // }
  61. func (p *mapBuildUpgradeConfig) List() []*MapBuildUpgradeRow {
  62. return p.list
  63. }
  64. func (p *mapBuildUpgradeConfig) ListByConfigID(configID int32) ([]*MapBuildUpgradeRow, bool) {
  65. value, found := p.configIDListMaps[configID]
  66. return value, found
  67. }
  68. func (p *mapBuildUpgradeConfig) ListContainConfigID(configID int32) bool {
  69. _, found := p.configIDListMaps[configID]
  70. return found
  71. }
  72. func (p *mapBuildUpgradeConfig) GetByConfigIDLevel(configID int32, level int32) (*MapBuildUpgradeRow, bool) {
  73. mapItem, found := p.configIDLevelUniMaps[configID]
  74. if !found {
  75. return nil, false
  76. }
  77. value, found := mapItem[level]
  78. return value, found
  79. }
  80. func (p *mapBuildUpgradeConfig) ContainConfigIDLevel(configID int32, level int32) bool {
  81. mapItem, found := p.configIDLevelUniMaps[configID]
  82. if !found {
  83. return false
  84. }
  85. _, found = mapItem[level]
  86. return found
  87. }