50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package data
|
|
|
|
import (
|
|
"github.com/oylshe1314/framework/errors"
|
|
"github.com/oylshe1314/framework/util"
|
|
)
|
|
|
|
func (this *RigSmelterTable) check() error {
|
|
for _, d := range this.l {
|
|
if len(d.CostItemId) != len(d.TimesList) {
|
|
return errors.Error("incorrect 'RigSmelter' table, error: len(d.CostItemId) != len(d.TimesList), id: ", d.id())
|
|
}
|
|
if len(d.CostItemNum) != len(d.TimesList) {
|
|
return errors.Error("incorrect 'RigSmelter' table, error: len(d.CostItemNum) != len(d.TimesList), id: ", d.id())
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type RigSmelterTableExtend struct {
|
|
*RigSmelterTable
|
|
|
|
extList []*RigSmelter
|
|
extMap map[uint64]*RigSmelter
|
|
}
|
|
|
|
func (this *RigSmelterTableExtend) init() error {
|
|
if this.RigSmelterTable == nil {
|
|
return nil
|
|
}
|
|
|
|
this.extMap = map[uint64]*RigSmelter{}
|
|
for _, d := range this.l {
|
|
if d.Level == 1 {
|
|
this.extList = append(this.extList, d)
|
|
}
|
|
this.extMap[util.Compose2uint32(uint32(d.Type), uint32(d.Level))] = d
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (this *RigSmelterTableExtend) List() []*RigSmelter {
|
|
return this.extList
|
|
}
|
|
|
|
func (this *RigSmelterTableExtend) Get(tipe, level int) *RigSmelter {
|
|
return this.extMap[util.Compose2uint32(uint32(tipe), uint32(level))]
|
|
}
|