58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package data
|
|
|
|
import json "github.com/json-iterator/go"
|
|
|
|
type Equip struct {
|
|
Id int `json:"id"`
|
|
ItemId int `json:"item_id"`
|
|
Quality int `json:"quality"`
|
|
Type int `json:"type"`
|
|
Levels int `json:"levels"`
|
|
RefineLevels int `json:"refine_levels"`
|
|
SetId int `json:"set_id"`
|
|
Holes1 int `json:"holes1"`
|
|
OpenedHoles1 int `json:"opened_holes1"`
|
|
Holes2 int `json:"holes2"`
|
|
OpenedHoles2 int `json:"opened_holes2"`
|
|
UnlockArgs1 []int `json:"unlock_args1"`
|
|
UnlockArgs2 []int `json:"unlock_args2"`
|
|
}
|
|
|
|
type EquipTable struct {
|
|
l []*Equip
|
|
m1 map[int]*Equip
|
|
m2 map[int]*Equip
|
|
}
|
|
|
|
func (this *EquipTable) load(buf []byte) error {
|
|
var err = json.Unmarshal(buf, &this.l)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
this.m1 = make(map[int]*Equip)
|
|
this.m2 = make(map[int]*Equip)
|
|
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 *EquipTable) List() []*Equip {
|
|
return this.l
|
|
}
|
|
|
|
//func (this *EquipTable) Get(i int) *Equip {
|
|
// return this.l[i]
|
|
//}
|
|
|
|
func (this *EquipTable) Find1(id int) *Equip {
|
|
return this.m1[id]
|
|
}
|
|
|
|
func (this *EquipTable) Find2(itemId int) *Equip {
|
|
return this.m2[itemId]
|
|
}
|