ecs/servers/game/data/hero.go
2025-06-04 18:17:39 +08:00

49 lines
977 B
Go

package data
import json "github.com/json-iterator/go"
type Hero struct {
Id int `json:"id"`
Sex int `json:"sex"`
Skill []int `json:"skill"`
Quality int `json:"quality"`
Country int `json:"country"`
Level int `json:"level"`
BreakType int `json:"break_type"`
BreaksLevels int `json:"breaks_levels"`
SoulLevels int `json:"soul_levels"`
ArousalLevels int `json:"arousal_levels"`
Boundary int `json:"boundary"`
}
type HeroTable struct {
l []*Hero
m map[int]*Hero
}
func (this *HeroTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int]*Hero)
for i := range this.l {
this.m[this.l[i].Id] = this.l[i]
}
return nil
}
func (this *HeroTable) List() []*Hero {
return this.l
}
func (this *HeroTable) Get(i int) *Hero {
return this.l[i]
}
func (this *HeroTable) Find(id int) *Hero {
return this.m[id]
}