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