equip_level.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/enum"
  5. "f1-game/internal/types"
  6. )
  7. var EquipLevel = &equipLevelConfig{}
  8. func init() {
  9. _allList = append(_allList, EquipLevel)
  10. }
  11. type (
  12. EquipLevelRow struct {
  13. Quality enum.Quality `json:"Quality"` // 品质
  14. Level int32 `json:"Level"` // 等级
  15. EnhanceCosts types.Assets `json:"EnhanceCosts"` // 强化消耗
  16. DimantleRewards types.Assets `json:"DimantleRewards"` // 分解所得
  17. SuccessProb int32 `json:"SuccessProb"` // 成功概率
  18. BaseAttrAddPer int64 `json:"BaseAttrAddPer"` // 基础属性提升万分比
  19. }
  20. equipLevelConfig struct {
  21. baseConfig
  22. list []*EquipLevelRow // all list
  23. qualityLevelUniMaps map[enum.Quality]map[int32]*EquipLevelRow // key:quality, level
  24. }
  25. )
  26. func (p *equipLevelConfig) Name() string {
  27. return "equip_level"
  28. }
  29. func (p *equipLevelConfig) Init() {
  30. p.qualityLevelUniMaps = map[enum.Quality]map[int32]*EquipLevelRow{}
  31. }
  32. func (p *equipLevelConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  33. if reload && p.denyLoad {
  34. return 0, nil
  35. }
  36. var list []*EquipLevelRow
  37. if err := DecodeData(maps, &list); err != nil {
  38. return 0, err
  39. }
  40. p.list = list
  41. qualityLevelUniMaps := map[enum.Quality]map[int32]*EquipLevelRow{}
  42. for _, row := range list {
  43. itemMap := qualityLevelUniMaps[row.Quality]
  44. if itemMap == nil {
  45. itemMap = map[int32]*EquipLevelRow{}
  46. qualityLevelUniMaps[row.Quality] = itemMap
  47. }
  48. itemMap[row.Level] = row
  49. }
  50. p.qualityLevelUniMaps = qualityLevelUniMaps
  51. return len(list), nil
  52. }
  53. // func (p *equipLevelConfig) OnAfterLoad(_ bool) {
  54. // }
  55. func (p *equipLevelConfig) List() []*EquipLevelRow {
  56. return p.list
  57. }
  58. func (p *equipLevelConfig) GetByQualityLevel(quality enum.Quality, level int32) (*EquipLevelRow, bool) {
  59. mapItem, found := p.qualityLevelUniMaps[quality]
  60. if !found {
  61. return nil, false
  62. }
  63. value, found := mapItem[level]
  64. return value, found
  65. }
  66. func (p *equipLevelConfig) ContainQualityLevel(quality enum.Quality, level int32) bool {
  67. mapItem, found := p.qualityLevelUniMaps[quality]
  68. if !found {
  69. return false
  70. }
  71. _, found = mapItem[level]
  72. return found
  73. }