ecs/servers/game/data/monster.go
2025-06-20 15:34:32 +08:00

65 lines
1.7 KiB
Go

package data
import json "github.com/json-iterator/go"
type Monster struct {
Id int `json:"id"`
Gender int `json:"gender"`
Country int `json:"country"`
Level int `json:"level"`
Speed int `json:"speed"`
AttackSkills []int `json:"attack_skills"`
PassiveSkills []int `json:"passive_skills"`
AttrValue1 int `json:"attr_value1"`
AttrValue2 int `json:"attr_value2"`
AttrValue3 int `json:"attr_value3"`
AttrValue4 int `json:"attr_value4"`
AttrValue5 int `json:"attr_value5"`
AttrValue6 int `json:"attr_value6"`
AttrValue7 int `json:"attr_value7"`
AttrValue8 int `json:"attr_value8"`
AttrValue9 int `json:"attr_value9"`
AttrValue10 int `json:"attr_value10"`
AttrValue11 int `json:"attr_value11"`
AttrValue12 int `json:"attr_value12"`
AttrValue13 int `json:"attr_value13"`
AttrValue14 int `json:"attr_value14"`
AttrValue15 int `json:"attr_value15"`
AttrValue16 int `json:"attr_value16"`
AttrValue17 int `json:"attr_value17"`
AttrValue18 int `json:"attr_value18"`
AttrValue19 int `json:"attr_value19"`
AttrValue20 int `json:"attr_value20"`
}
type MonsterTable struct {
l []*Monster
m map[int]*Monster
}
func (this *MonsterTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int]*Monster)
for i := range this.l {
this.m[this.l[i].Id] = this.l[i]
}
return nil
}
func (this *MonsterTable) List() []*Monster {
return this.l
}
//func (this *MonsterTable) Get(i int) *Monster {
// return this.l[i]
//}
func (this *MonsterTable) Find(id int) *Monster {
return this.m[id]
}