equip_attr_extra.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. type (
  4. EquipAttrExtraRow struct {
  5. PoolID int32 `json:"PoolID"` // 池ID
  6. No int32 `json:"No"` // 序号
  7. Key int32 `json:"Key"` // 属性键
  8. MinValue int64 `json:"MinValue"` // 最小属性值
  9. MaxValue int64 `json:"MaxValue"` // 最大属性值
  10. Weight int32 `json:"Weight"` // 权重
  11. }
  12. equipAttrExtraConfig struct {
  13. baseConfig
  14. list []*EquipAttrExtraRow // all list
  15. poolIDNoUniMaps map[int32]map[int32]*EquipAttrExtraRow // key:poolID, no
  16. }
  17. )
  18. func (p *equipAttrExtraConfig) Name() string {
  19. return "equip_attr_extra"
  20. }
  21. func (p *equipAttrExtraConfig) Init() {
  22. p.poolIDNoUniMaps = map[int32]map[int32]*EquipAttrExtraRow{}
  23. }
  24. func (p *equipAttrExtraConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  25. if reload && p.denyLoad {
  26. return 0, nil
  27. }
  28. var list []*EquipAttrExtraRow
  29. if err := DecodeData(maps, &list); err != nil {
  30. return 0, err
  31. }
  32. p.list = list
  33. poolIDNoUniMaps := map[int32]map[int32]*EquipAttrExtraRow{}
  34. for _, row := range list {
  35. itemMap := poolIDNoUniMaps[row.PoolID]
  36. if itemMap == nil {
  37. itemMap = map[int32]*EquipAttrExtraRow{}
  38. poolIDNoUniMaps[row.PoolID] = itemMap
  39. }
  40. itemMap[row.No] = row
  41. }
  42. p.poolIDNoUniMaps = poolIDNoUniMaps
  43. return len(list), nil
  44. }
  45. // func (p *equipAttrExtraConfig) OnAfterLoad(_ bool) {
  46. // }
  47. func (p *equipAttrExtraConfig) List() []*EquipAttrExtraRow {
  48. return p.list
  49. }
  50. func (p *equipAttrExtraConfig) GetByPoolIDNo(poolID int32, no int32) (*EquipAttrExtraRow, bool) {
  51. mapItem, found := p.poolIDNoUniMaps[poolID]
  52. if !found {
  53. return nil, false
  54. }
  55. value, found := mapItem[no]
  56. return value, found
  57. }
  58. func (p *equipAttrExtraConfig) ContainPoolIDNo(poolID int32, no int32) bool {
  59. mapItem, found := p.poolIDNoUniMaps[poolID]
  60. if !found {
  61. return false
  62. }
  63. _, found = mapItem[no]
  64. return found
  65. }