65 lines
1.6 KiB
Go
65 lines
1.6 KiB
Go
package data
|
|
|
|
import (
|
|
json "github.com/json-iterator/go"
|
|
"github.com/oylshe1314/framework/util"
|
|
)
|
|
|
|
type EquipRefine struct {
|
|
Id int `json:"id"`
|
|
EquipId int `json:"equip_id"`
|
|
RefineLevel int `json:"refine_level"`
|
|
NeedExp int `json:"need_exp"`
|
|
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 EquipRefineTable struct {
|
|
l []*EquipRefine
|
|
m1 map[int]*EquipRefine
|
|
m2 map[int][]*EquipRefine
|
|
m3 map[uint64]*EquipRefine
|
|
}
|
|
|
|
func (this *EquipRefineTable) load(buf []byte) error {
|
|
var err = json.Unmarshal(buf, &this.l)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
this.m1 = make(map[int]*EquipRefine)
|
|
this.m2 = make(map[int][]*EquipRefine)
|
|
this.m3 = make(map[uint64]*EquipRefine)
|
|
for i := range this.l {
|
|
this.m1[this.l[i].Id] = this.l[i]
|
|
this.m2[this.l[i].EquipId] = append(this.m2[this.l[i].EquipId], this.l[i])
|
|
this.m3[util.Compose2uint32(uint32(this.l[i].EquipId), uint32(this.l[i].RefineLevel))] = this.l[i]
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (this *EquipRefineTable) List() []*EquipRefine {
|
|
return this.l
|
|
}
|
|
|
|
//func (this *EquipRefineTable) Get(i int) *EquipRefine {
|
|
// return this.l[i]
|
|
//}
|
|
|
|
func (this *EquipRefineTable) Find1(id int) *EquipRefine {
|
|
return this.m1[id]
|
|
}
|
|
|
|
func (this *EquipRefineTable) Find2(equipId int) []*EquipRefine {
|
|
return this.m2[equipId]
|
|
}
|
|
|
|
func (this *EquipRefineTable) Find3(equipId, refineLevel int) *EquipRefine {
|
|
return this.m3[util.Compose2uint32(uint32(equipId), uint32(refineLevel))]
|
|
}
|