ecs/servers/game/data/upgrade_master.go

48 lines
1.2 KiB
Go

package data
import (
json "github.com/json-iterator/go"
"github.com/oylshe1314/framework/util"
)
type UpgradeMaster struct {
Id int `json:"id"`
Type int `json:"type"`
Level int `json:"level"`
NeedLevel int `json:"need_level"`
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"`
}
type UpgradeMasterTable struct {
l []*UpgradeMaster
m1 map[int][]*UpgradeMaster
m2 map[uint64]*UpgradeMaster
}
func (this *UpgradeMasterTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m1 = make(map[int][]*UpgradeMaster)
this.m2 = make(map[uint64]*UpgradeMaster)
for i := range this.l {
this.m1[this.l[i].Type] = append(this.m1[this.l[i].Type], this.l[i])
this.m2[util.Compose2uint32(uint32(this.l[i].Type), uint32(this.l[i].Level))] = this.l[i]
}
return nil
}