ecs/servers/game/data/equip.go

47 lines
925 B
Go
Raw Normal View History

2025-06-04 18:17:39 +08:00
package data
import json "github.com/json-iterator/go"
type Equip struct {
Id int `json:"id"`
Quality int `json:"quality"`
Type int `json:"type"`
Levels int `json:"levels"`
SetId int `json:"set_id"`
Holes int `json:"holes"`
OpenedHoles int `json:"opened_holes"`
HoleUnlockType []int `json:"hole_unlock_type"`
HoleUnlockArgs []int `json:"hole_unlock_args"`
}
type EquipTable struct {
l []*Equip
m map[int]*Equip
}
func (this *EquipTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int]*Equip)
for i := range this.l {
this.m[this.l[i].Id] = this.l[i]
}
return nil
}
func (this *EquipTable) List() []*Equip {
return this.l
}
func (this *EquipTable) Get(i int) *Equip {
return this.l[i]
}
func (this *EquipTable) Find(id int) *Equip {
return this.m[id]
}