hero_star_attrs.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var HeroStarAttrs = &heroStarAttrsConfig{}
  4. func init() {
  5. _allList = append(_allList, HeroStarAttrs)
  6. }
  7. type (
  8. HeroStarAttrsRow struct {
  9. HeroID int32 `json:"HeroID"` // 英雄ID
  10. Star int32 `json:"Star"` // 星级 主键,英雄星级 = star
  11. Health int64 `json:"Health"` // 血量
  12. Attack int64 `json:"Attack"` // 攻击
  13. Defense int64 `json:"Defense"` // 防御
  14. }
  15. heroStarAttrsConfig struct {
  16. baseConfig
  17. list []*HeroStarAttrsRow // all list
  18. heroIDStarUniMaps map[int32]map[int32]*HeroStarAttrsRow // key:heroID, star
  19. }
  20. )
  21. func (p *heroStarAttrsConfig) Name() string {
  22. return "hero_star_attrs"
  23. }
  24. func (p *heroStarAttrsConfig) Init() {
  25. p.heroIDStarUniMaps = map[int32]map[int32]*HeroStarAttrsRow{}
  26. }
  27. func (p *heroStarAttrsConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  28. if reload && p.denyLoad {
  29. return 0, nil
  30. }
  31. var list []*HeroStarAttrsRow
  32. if err := DecodeData(maps, &list); err != nil {
  33. return 0, err
  34. }
  35. p.list = list
  36. heroIDStarUniMaps := map[int32]map[int32]*HeroStarAttrsRow{}
  37. for _, row := range list {
  38. itemMap := heroIDStarUniMaps[row.HeroID]
  39. if itemMap == nil {
  40. itemMap = map[int32]*HeroStarAttrsRow{}
  41. heroIDStarUniMaps[row.HeroID] = itemMap
  42. }
  43. itemMap[row.Star] = row
  44. }
  45. p.heroIDStarUniMaps = heroIDStarUniMaps
  46. return len(list), nil
  47. }
  48. // func (p *heroStarAttrsConfig) OnAfterLoad(_ bool) {
  49. // }
  50. func (p *heroStarAttrsConfig) List() []*HeroStarAttrsRow {
  51. return p.list
  52. }
  53. func (p *heroStarAttrsConfig) GetByHeroIDStar(heroID int32, star int32) (*HeroStarAttrsRow, bool) {
  54. mapItem, found := p.heroIDStarUniMaps[heroID]
  55. if !found {
  56. return nil, false
  57. }
  58. value, found := mapItem[star]
  59. return value, found
  60. }
  61. func (p *heroStarAttrsConfig) ContainHeroIDStar(heroID int32, star int32) bool {
  62. mapItem, found := p.heroIDStarUniMaps[heroID]
  63. if !found {
  64. return false
  65. }
  66. _, found = mapItem[star]
  67. return found
  68. }