57 lines
1.2 KiB
Go
57 lines
1.2 KiB
Go
package data
|
|
|
|
import json "github.com/json-iterator/go"
|
|
|
|
type Hero struct {
|
|
Id int `json:"id"`
|
|
ItemId int `json:"item_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
|
|
m1 map[int]*Hero
|
|
m2 map[int]*Hero
|
|
}
|
|
|
|
func (this *HeroTable) load(buf []byte) error {
|
|
var err = json.Unmarshal(buf, &this.l)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
this.m1 = make(map[int]*Hero)
|
|
this.m2 = make(map[int]*Hero)
|
|
for i := range this.l {
|
|
this.m1[this.l[i].Id] = this.l[i]
|
|
this.m2[this.l[i].ItemId] = 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) Find1(id int) *Hero {
|
|
return this.m1[id]
|
|
}
|
|
|
|
func (this *HeroTable) Find2(itemId int) *Hero {
|
|
return this.m2[itemId]
|
|
}
|