49 lines
977 B
Go
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]
|
||
|
}
|