44 lines
894 B
Go
44 lines
894 B
Go
package data
|
|
|
|
import (
|
|
"github.com/oylshe1314/framework/util"
|
|
"time"
|
|
)
|
|
|
|
type _BattlePassSeasonExtend struct {
|
|
*BattlePassSeason
|
|
|
|
UnitxBeginTimne int64
|
|
}
|
|
|
|
type BattlePassSeasonTableExtend struct {
|
|
*BattlePassSeasonTable
|
|
|
|
extList []*_BattlePassSeasonExtend
|
|
}
|
|
|
|
func (this *BattlePassSeasonTableExtend) init() error {
|
|
if this.BattlePassSeasonTable == nil {
|
|
return nil
|
|
}
|
|
|
|
for _, d := range this.l {
|
|
beginTime, err := util.ParseUnix(time.DateTime, d.BeginTime)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
this.extList = append(this.extList, &_BattlePassSeasonExtend{UnitxBeginTimne: beginTime, BattlePassSeason: d})
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (this *BattlePassSeasonTableExtend) Get(now int64) *BattlePassSeason {
|
|
for _, ext := range this.extList {
|
|
if now >= ext.UnitxBeginTimne && now < ext.UnitxBeginTimne+86400*int64(ext.ContinuousDay) {
|
|
return ext.BattlePassSeason
|
|
}
|
|
}
|
|
return nil
|
|
}
|