86 lines
2.7 KiB
Go
86 lines
2.7 KiB
Go
package data
|
|
|
|
import (
|
|
json "github.com/json-iterator/go"
|
|
"github.com/oylshe1314/framework/util"
|
|
)
|
|
|
|
type HeroBreak struct {
|
|
Id int `json:"id"`
|
|
HeroId int `json:"hero_id"`
|
|
BreakType int `json:"break_type"`
|
|
BreakNeed int `json:"break_need"`
|
|
BreakLevel int `json:"break_level"`
|
|
BreakName string `json:"break_name"`
|
|
ConsumeItems []int `json:"consume_items"`
|
|
ConsumeNums []int `json:"consume_nums"`
|
|
OptionalConsumeItems []int `json:"optional_consume_items"`
|
|
OptionalConsumeNums []int `json:"optional_consume_nums"`
|
|
PropertyType int `json:"property_type"`
|
|
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"`
|
|
AttrType4 int `json:"attr_type4"`
|
|
AttrValue4 int `json:"attr_value4"`
|
|
AttrType5 int `json:"attr_type5"`
|
|
AttrValue5 int `json:"attr_value5"`
|
|
AttrType6 int `json:"attr_type6"`
|
|
AttrValue6 int `json:"attr_value6"`
|
|
AttrType7 int `json:"attr_type7"`
|
|
AttrValue7 int `json:"attr_value7"`
|
|
AttrType8 int `json:"attr_type8"`
|
|
AttrValue8 int `json:"attr_value8"`
|
|
AttrType9 int `json:"attr_type9"`
|
|
AttrValue9 int `json:"attr_value9"`
|
|
AttrType10 int `json:"attr_type10"`
|
|
AttrValue10 int `json:"attr_value10"`
|
|
}
|
|
|
|
type HeroBreakTable struct {
|
|
l []*HeroBreak
|
|
m1 map[int]*HeroBreak
|
|
m2 map[int][]*HeroBreak
|
|
m3 map[uint64]*HeroBreak
|
|
}
|
|
|
|
func (this *HeroBreakTable) load(buf []byte) error {
|
|
var err = json.Unmarshal(buf, &this.l)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
this.m1 = make(map[int]*HeroBreak)
|
|
this.m2 = make(map[int][]*HeroBreak)
|
|
this.m3 = make(map[uint64]*HeroBreak)
|
|
for i := range this.l {
|
|
this.m1[this.l[i].Id] = this.l[i]
|
|
this.m2[this.l[i].HeroId] = append(this.m2[this.l[i].HeroId], this.l[i])
|
|
this.m3[util.Compose2uint32(uint32(this.l[i].HeroId), uint32(this.l[i].BreakLevel))] = this.l[i]
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (this *HeroBreakTable) List() []*HeroBreak {
|
|
return this.l
|
|
}
|
|
|
|
//func (this *HeroBreakTable) Get(i int) *HeroBreak {
|
|
// return this.l[i]
|
|
//}
|
|
|
|
func (this *HeroBreakTable) Find1(id int) *HeroBreak {
|
|
return this.m1[id]
|
|
}
|
|
|
|
func (this *HeroBreakTable) Find2(heroId int) []*HeroBreak {
|
|
return this.m2[heroId]
|
|
}
|
|
|
|
func (this *HeroBreakTable) Find3(heroId, breakLevel int) *HeroBreak {
|
|
return this.m3[util.Compose2uint32(uint32(heroId), uint32(breakLevel))]
|
|
}
|