ecs/servers/game/data/lottery_pool.go
2025-07-16 10:05:22 +08:00

66 lines
1.7 KiB
Go

package data
import (
json "github.com/json-iterator/go"
"github.com/oylshe1314/framework/util"
"time"
)
type LotteryPool struct {
Id int `json:"id"`
Type int `json:"type"`
LotteryTimes []int `json:"lottery_times"`
OrdinaryBoxId int `json:"ordinary_box_id"`
AdvancedBoxId int `json:"advanced_box_id"`
AdvancedBaseRate int `json:"advanced_base_rate"`
AdvancedAddRate int `json:"advanced_add_rate"`
FinalBoxId int `json:"final_box_id"`
AdvancedTimes int `json:"advanced_times"`
FinalTimes int `json:"final_times"`
ConsumeIds []int `json:"consume_ids"`
ConsumeNums []int `json:"consume_nums"`
Points int `json:"points"`
BeginTime string `json:"begin_time"`
RawBeginTime int64 `json:"-"`
EndTime string `json:"end_time"`
RawEndTime int64 `json:"-"`
}
type LotteryPoolTable struct {
l []*LotteryPool
m map[int]*LotteryPool
}
func (this *LotteryPoolTable) load(buf []byte) error {
var err = json.Unmarshal(buf, &this.l)
if err != nil {
return err
}
this.m = make(map[int]*LotteryPool)
for i := range this.l {
this.l[i].RawBeginTime, err = util.ParseUnix(time.DateTime, this.l[i].BeginTime)
if err != nil {
return err
}
this.l[i].RawEndTime, err = util.ParseUnix(time.DateTime, this.l[i].EndTime)
if err != nil {
return err
}
this.m[this.l[i].Id] = this.l[i]
}
return nil
}
func (this *LotteryPoolTable) List() []*LotteryPool {
return this.l
}
//func (this *LotteryPoolTable) Get(i int) *LotteryPool {
// return this.l[i]
//}
func (this *LotteryPoolTable) Find(id int) *LotteryPool {
return this.m[id]
}