ecs/servers/game/data/reward_active.go

50 lines
1.1 KiB
Go
Raw Normal View History

2025-06-21 16:17:24 +08:00
package data
import json "github.com/json-iterator/go"
type RewardActive struct {
Id int `json:"id"`
MoneyType int `json:"money_type"`
ActiveValue int `json:"active_value"`
ItemIds []int `json:"item_ids"`
ItemNums []int `json:"item_nums"`
}
type RewardActiveTable struct {
l []*RewardActive
m1 map[int]*RewardActive
m2 map[int][]*RewardActive
}
func (this *RewardActiveTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m1 = make(map[int]*RewardActive)
this.m2 = make(map[int][]*RewardActive)
for i := range this.l {
this.m1[this.l[i].Id] = this.l[i]
this.m2[this.l[i].MoneyType] = append(this.m2[this.l[i].Id], this.l[i])
}
return nil
}
func (this *RewardActiveTable) List() []*RewardActive {
return this.l
}
//func (this *RewardActiveTable) Get(i int) *RewardActive {
// return this.l[i]
//}
func (this *RewardActiveTable) Find1(id int) *RewardActive {
return this.m1[id]
}
func (this *RewardActiveTable) Find2(montyType int) []*RewardActive {
return this.m2[montyType]
}