package logic import ( "ecs/proto/pb" "github.com/oylshe1314/framework/util" ) func (this *Player) checkPerSecond(login bool, pre, cur *GameTime) { this.checkRecoveryPower(login, pre, cur) } func (this *Player) checkRecoveryPower(login bool, pre, cur *GameTime) { var money = this.GetMoney(pb.MoneyType_Power) if money.Value >= uint32(RolePowerMax) { if this.PowerNextTime != 0 { this.ChangeProperty(util.NewPair(pb.RolePropertyType_PowerNextTime, int64(0))) } return } if cur.Timestamp < this.PowerNextTime { return } money.Value += uint32(RolePowerRegain) this.SaveModel(money) if money.Value >= uint32(RolePowerMax) { this.ChangeProperty(util.NewPair(pb.RolePropertyType_PowerNextTime, int64(0))) } else { this.ChangeProperty(util.NewPair(pb.RolePropertyType_PowerNextTime, cur.Timestamp+int64(RolePowerCycle))) } _ = this.Send(pb.ModId_ModuleRole, pb.MsgId_ModRoleMoneyChange, &pb.MoneyListAck{MoneyList: []*pb.Money{money.BuildMsgMoney()}}) } func (this *Player) checkAcrossTime(login bool, pre, cur *GameTime, handles ...func(login bool, pre, cur *GameTime) bool) bool { var refreshed = false for _, handle := range handles { refreshed = handle(login, pre, cur) || refreshed } return refreshed } func (this *Player) checkRefresh(login bool, pre, cur *GameTime) { this.checkPerSecond(login, pre, cur) if this.checkAcrossTime(login, pre, cur, this.checkLoginDays, this.checkTaskRefresh, //this.checkMonthlyCard, //this.checkIdleBattle, //this.checkCopyRefresh, //this.checkPlanetRawStone, //this.checkStoreRefresh, //this.checkStorePoolRefresh, //this.checkGiftPackRefresh, //this.checkRecvRegionMail, //this.checkAdCounterReset, //this.checkRaderEndTime, ) { this.RefreshTime = cur.Timestamp this.SaveField("refresh_time", this.RefreshTime) } } func (this *Player) checkLoginDays(login bool, pre, cur *GameTime) bool { if cur.Days == pre.Days { return false } this.ChangeProperty(util.NewPair(pb.RolePropertyType_LoginDays, int64(this.LoginDays+1))) //this.CheckRewardLogin() //this.CheckTask(proto.TaskSection1LoginDays, 0, 1) //this.CheckAchievement(proto.AchievementTypeLoginDays, 0, 1) return true } func (this *Player) checkTaskRefresh(login bool, pre, cur *GameTime) (changed bool) { if login { changed = this.checkTaskDeprecated() } if pre.Days != cur.Days { changed = this.MoneyActiveValueReset(pb.MoneyType_DailyActive) || changed changed = this.checkTaskReset(pb.TaskType_TaskDaily) || changed } if pre.Weeks != cur.Weeks { changed = this.checkTaskReset(pb.TaskType_TaskWeekly) || changed } return changed } //func (this *Player) checkMonthlyCard(login bool, pre, cur *GameTime) (changed bool) { // if cur.Days == pre.Days { // return false // } // // return this.checkMonthlyCardReward(cur.Timestamp) //} // //func (this *Player) checkIdleBattle(login bool, pre, cur *GameTime) (changed bool) { // if this.Role.CopyMainSceneId == 0 { // return false // } // // if cur.Days != pre.Days { // this.ResetCounterDaily(proto.CounterTypeIdleQuickBattle, 1) // } // // return this.idleBattleReward(cur.Timestamp) //} // //func (this *Player) checkCopyRefresh(login bool, pre, cur *GameTime) (changed bool) { // if cur.Days == pre.Days { // return false // } // // for _, tipe := range this.manager.tables.CopyMaterialExtend.Types() { // changed = this.ResetCounterDaily(proto.CounterTypeCopyMaterial, uint32(tipe)) || changed // } // // for _, tipe := range this.manager.tables.CopySpeedExtend.Types() { // changed = this.ResetCounterDaily(proto.CounterTypeCopySpeed, uint32(tipe)) || changed // } // // for _, copyArenaTable := range this.manager.tables.CopyArena.List() { // changed = this.ResetCounterDaily(proto.CounterTypeCopyArena, uint32(copyArenaTable.Id)) || changed // changed = this.ResetCounterDaily(proto.CounterTypeCopyArenaRefresh, uint32(copyArenaTable.Id)) || changed // } // // if cur.Weeks != pre.Weeks { // changed = this.resetCopySpeedStatus(uint32(cur.Weeks)) || changed // } // // return true //} // //func (this *Player) checkPlanetRawStone(login bool, pre, cur *GameTime) bool { // return this.checkRawStoneFreeTime(cur) //} // //func (this *Player) checkStoreRefresh(login bool, pre, cur *GameTime) (changed bool) { // if cur.Days == pre.Days { // return false // } // // var shopTables = this.manager.tables.Shop.List() // for _, shopTable := range shopTables { // switch shopTable.TimeNum { // case 0: //reset never // continue // case 1: //reset daily // if this.GetCounterDaily(proto.CounterTypeStoreBuy, uint32(shopTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeStoreBuy, uint32(shopTable.Id)) // } // changed = true // case 7: //reset weekly // if cur.Weeks != pre.Weeks && this.GetCounterDaily(proto.CounterTypeStoreBuy, uint32(shopTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeStoreBuy, uint32(shopTable.Id)) // changed = true // } // case 30: //reset monthly // if cur.Months != pre.Months && this.GetCounterDaily(proto.CounterTypeStoreBuy, uint32(shopTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeStoreBuy, uint32(shopTable.Id)) // changed = true // } // } // } // // return changed //} // //func (this *Player) checkStorePoolRefresh(login bool, pre, cur *GameTime) (changed bool) { // for _, storePool := range this.StorePool { // if cur.Days != pre.Days { // this.ResetCounterDaily(proto.CounterTypeStorePoolRefresh, storePool.Type) // } // // if storePool.NextTime > cur.Timestamp { // continue // } // // var poolTable = this.manager.tables.ShopPool.Get(int(storePool.Id)) // if poolTable == nil { // continue // } // // this.RefreshStorePool(storePool, false, cur.Timestamp, this.manager.tables.ShopPool.Get(int(storePool.Id))) // changed = true // } // return //} // //func (this *Player) checkGiftPackRefresh(login bool, pre, cur *GameTime) (changed bool) { // changed = this.checkGiftPackTimeout(cur.Timestamp) // if cur.Days == pre.Days { // return // } // // var giftTables = this.manager.tables.ChargeGift.List() // for _, giftTable := range giftTables { // switch giftTable.BagType { // case 0: //time limit // if this.GetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) > 0 { // if cur.Timestamp < giftTable.BeginTime || (giftTable.EndTime > 0 && cur.Timestamp >= giftTable.EndTime) { // this.ResetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) // changed = true // } // } // case 1: //reset monthly // if cur.Months != pre.Months && this.GetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) // changed = true // } // case 2: //reset weekly // if cur.Weeks != pre.Weeks && this.GetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) // changed = true // } // case 3: //reset daily // if this.GetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeCharge, uint32(giftTable.Id)) // changed = true // } // case 4: //reset never // continue // } // } // // return changed //} // //func (this *Player) checkRecvRegionMail(login bool, pre, cur *GameTime) (changed bool) { // return this.manager.RegionMailRecv(this) //} // //func (this *Player) checkAdCounterReset(login bool, pre, cur *GameTime) (changed bool) { // if cur.Days == pre.Days { // return // } // // for _, adTable := range this.manager.tables.Ad.List() { // if this.GetCounterDaily(proto.CounterTypeAdWatching, uint32(adTable.Id)) > 0 { // this.ResetCounterDaily(proto.CounterTypeAdWatching, uint32(adTable.Id)) // changed = true // } // } // return //} // //func (this *Player) checkRaderEndTime(login bool, pre, cur *GameTime) (changed bool) { // if this.Role.RadarEndTime == 0 { // return false // } // // if cur.Timestamp < this.Role.RadarEndTime { // return false // } // // this.ChangeProperty(util.NewPair(proto.RolePropertyTypeRadarEndTime, uint64(0))) // return true //}