ecs/servers/game/data/hero_bond.go

48 lines
1.0 KiB
Go

package data
import json "github.com/json-iterator/go"
type HeroBond struct {
Id int `json:"id"`
HeroId int `json:"hero_id"`
BondType int `json:"bond_type"`
BondId []int `json:"bond_id"`
AttrType1 int `json:"attr_type1"`
AttrValue1 int `json:"attr_value1"`
AttrType2 int `json:"attr_type2"`
AttrValue2 int `json:"attr_value2"`
AttrType3 int `json:"attr_type3"`
AttrValue3 int `json:"attr_value3"`
}
type HeroBondTable struct {
l []*HeroBond
m map[int][]*HeroBond
}
func (this *HeroBondTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int][]*HeroBond)
for i := range this.l {
this.m[this.l[i].HeroId] = append(this.m[this.l[i].HeroId], this.l[i])
}
return nil
}
func (this *HeroBondTable) List() []*HeroBond {
return this.l
}
//func (this *HeroBondTable) Get(i int) *HeroBond {
// return this.l[i]
//}
func (this *HeroBondTable) Find(heroId int) []*HeroBond {
return this.m[heroId]
}