league_tech_level.go 2.2 KB

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