恢复时间计算
This commit is contained in:
parent
950261af45
commit
809d5d2dc5
@ -63,15 +63,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
|
|||||||
if list.RecoveryTime == 0 {
|
if list.RecoveryTime == 0 {
|
||||||
list.RecoveryTime = configure.Now().Unix()
|
list.RecoveryTime = configure.Now().Unix()
|
||||||
}
|
}
|
||||||
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.HuntingRecovery*60)
|
for { // 计算恢复时间
|
||||||
if count > 1 {
|
if list.RecoveryTime+int64(conf.HuntingRecovery*60) <= configure.Now().Unix() {
|
||||||
curCount += int32(count)
|
curCount++
|
||||||
}
|
list.RecoveryTime += int64(conf.HuntingRecovery * 60)
|
||||||
if curCount >= conf.HuntingNum {
|
if curCount >= conf.HuntingNum {
|
||||||
curCount = conf.HuntingNum
|
list.RecoveryTime = 0
|
||||||
list.RecoveryTime = 0
|
break
|
||||||
} else {
|
}
|
||||||
list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if curCount-amount > 0 {
|
if curCount-amount > 0 {
|
||||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
||||||
@ -88,14 +90,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
|
|||||||
mapData["recoveryTime"] = list.RecoveryTime
|
mapData["recoveryTime"] = list.RecoveryTime
|
||||||
curByCount += req.Count // 当前需要购买的数量
|
curByCount += req.Count // 当前需要购买的数量
|
||||||
if this.configure.GetMaxBuyChallengeCount() < curByCount {
|
if this.configure.GetMaxBuyChallengeCount() < curByCount {
|
||||||
code = pb.ErrorCode_VikingBuyMaxCount
|
code = pb.ErrorCode_HuntingBuyMaxCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := list.BuyCount + 1; i <= curByCount; i++ {
|
for i := list.BuyCount + 1; i <= curByCount; i++ {
|
||||||
_cfg := this.configure.GetBuyChallengeCount(i)
|
_cfg := this.configure.GetBuyChallengeCount(i)
|
||||||
if _cfg == nil {
|
if _cfg == nil {
|
||||||
code = pb.ErrorCode_VikingBuyMaxCount
|
code = pb.ErrorCode_HuntingBuyMaxCount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
szCostRes = append(szCostRes, _cfg.Need...)
|
szCostRes = append(szCostRes, _cfg.Need...)
|
||||||
|
@ -46,34 +46,30 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe
|
|||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
costRes := conf.VikingExpeditionCos
|
costRes := conf.HuntingCos
|
||||||
if costRes == nil {
|
if costRes == nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量
|
amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量
|
||||||
curCount = amount
|
curCount = amount
|
||||||
if amount < conf.VikingNum {
|
if amount < conf.HuntingNum {
|
||||||
if list.RecoveryTime == 0 {
|
if list.RecoveryTime == 0 {
|
||||||
list.RecoveryTime = configure.Now().Unix()
|
list.RecoveryTime = configure.Now().Unix()
|
||||||
}
|
}
|
||||||
for { // 计算恢复时间
|
for { // 计算恢复时间
|
||||||
amount++
|
if list.RecoveryTime+int64(conf.HuntingRecovery*60) <= configure.Now().Unix() {
|
||||||
if amount > conf.VikingNum {
|
curCount++
|
||||||
list.RecoveryTime = 0
|
list.RecoveryTime += int64(conf.HuntingRecovery * 60)
|
||||||
|
if curCount >= conf.HuntingNum {
|
||||||
|
list.RecoveryTime = 0
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.HuntingRecovery*60) // 暂时用维京配置 11月21号统一修改配置
|
|
||||||
if count > 1 {
|
|
||||||
curCount += int32(count)
|
|
||||||
}
|
|
||||||
if curCount > conf.VikingNum {
|
|
||||||
curCount = conf.VikingNum
|
|
||||||
list.RecoveryTime = 0
|
|
||||||
} else {
|
|
||||||
list.RecoveryTime += count * int64(conf.HuntingRecovery*60) // 更新刷新时间
|
|
||||||
}
|
|
||||||
addCount := curCount - amount
|
addCount := curCount - amount
|
||||||
if addCount > 0 {
|
if addCount > 0 {
|
||||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
||||||
|
@ -64,19 +64,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
|
|||||||
if list.RecoveryTime == 0 {
|
if list.RecoveryTime == 0 {
|
||||||
list.RecoveryTime = configure.Now().Unix()
|
list.RecoveryTime = configure.Now().Unix()
|
||||||
}
|
}
|
||||||
if conf.VikingExpeditionRecoveryTime == 0 { // 配置校验 被除数不能为0
|
for { // 计算恢复时间
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
if list.RecoveryTime+int64(conf.VikingExpeditionRecoveryTime*60) <= configure.Now().Unix() {
|
||||||
return
|
curCount++
|
||||||
}
|
list.RecoveryTime += int64(conf.VikingExpeditionRecoveryTime * 60)
|
||||||
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
|
if curCount >= conf.HuntingNum {
|
||||||
if count > 1 {
|
list.RecoveryTime = 0
|
||||||
curCount += int32(count)
|
break
|
||||||
}
|
}
|
||||||
if curCount > conf.VikingNum {
|
} else {
|
||||||
curCount = conf.VikingNum
|
break
|
||||||
list.RecoveryTime = 0
|
}
|
||||||
} else {
|
|
||||||
list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间
|
|
||||||
}
|
}
|
||||||
if curCount-amount > 0 {
|
if curCount-amount > 0 {
|
||||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
||||||
|
@ -59,15 +59,17 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
|||||||
if list.RecoveryTime == 0 {
|
if list.RecoveryTime == 0 {
|
||||||
list.RecoveryTime = configure.Now().Unix()
|
list.RecoveryTime = configure.Now().Unix()
|
||||||
}
|
}
|
||||||
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
|
for { // 计算恢复时间
|
||||||
if count > 1 {
|
if list.RecoveryTime+int64(conf.VikingExpeditionRecoveryTime*60) <= configure.Now().Unix() {
|
||||||
curCount += int32(count)
|
curCount++
|
||||||
}
|
list.RecoveryTime += int64(conf.VikingExpeditionRecoveryTime * 60)
|
||||||
if curCount >= conf.VikingNum {
|
if curCount >= conf.HuntingNum {
|
||||||
curCount = conf.VikingNum
|
list.RecoveryTime = 0
|
||||||
list.RecoveryTime = 0
|
break
|
||||||
} else {
|
}
|
||||||
list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
addCount := curCount - amount
|
addCount := curCount - amount
|
||||||
if addCount > 0 {
|
if addCount > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user