随机任务+订单跨天bug
This commit is contained in:
parent
812155fc7d
commit
6339f7c0ad
2
go.mod
2
go.mod
@ -131,7 +131,7 @@ require (
|
||||
github.com/pelletier/go-toml v1.9.3 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
|
||||
github.com/philhofer/fwd v1.1.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/sftp v1.13.5
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||
|
2
go.sum
2
go.sum
@ -678,12 +678,10 @@ github.com/smallnest/quick v0.0.0-20220103065406-780def6371e6 h1:J8xk0QMMrqfDLqU
|
||||
github.com/smallnest/quick v0.0.0-20220103065406-780def6371e6/go.mod h1:h+J5yoLzf3XMKtM9l4vOaUtS4e+si6T3sKDtheJ15wc=
|
||||
github.com/smallnest/rpcx v1.7.4 h1:u6ADk/Ep8BqtAoJZO7LbniWsP+nqeAtcbaPm2D4eOXg=
|
||||
github.com/smallnest/rpcx v1.7.4/go.mod h1:TSciUoPlm8MYxnC7ErCz5ZymOFxOTbhN9cRgEI6Degs=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
|
||||
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
|
||||
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
|
||||
|
@ -71,9 +71,14 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
costTime int32
|
||||
curTime int32
|
||||
szTime map[int32]int32
|
||||
zTime int64
|
||||
nextDay bool
|
||||
nextDayTime int32
|
||||
)
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
szTime = make(map[int32]int32, 0)
|
||||
defer this.module.ModifyGourmetData(uid, mapData)
|
||||
|
||||
// 记录每个食材耗时
|
||||
for k, v := range gourmet.Skill {
|
||||
var _time int32
|
||||
@ -89,6 +94,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
}
|
||||
if !utils.IsToday(gourmet.Ctime) {
|
||||
gourmet.Ctime = time.Now().Unix()
|
||||
zTime = utils.GetZeroTime()
|
||||
}
|
||||
|
||||
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 {
|
||||
@ -97,9 +103,6 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
return
|
||||
}
|
||||
}
|
||||
if gourmet.CookingFood == nil {
|
||||
gourmet.CookingFood = &pb.Cooking{}
|
||||
}
|
||||
|
||||
for _, order := range gourmet.Foods {
|
||||
if order.FoodCount == 0 {
|
||||
@ -115,6 +118,22 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
if order.FoodCount == 0 {
|
||||
order.CookTime = 0
|
||||
}
|
||||
order.CookTime -= szTime[order.FoodType]
|
||||
if gourmet.CookingFood == nil {
|
||||
gourmet.CookingFood = &pb.Cooking{}
|
||||
gourmet.CookingFood.STime = time.Now().Unix()
|
||||
gourmet.CookingFood.ETime = time.Now().Unix()
|
||||
}
|
||||
gourmet.CookingFood.FoodType = order.FoodType
|
||||
gourmet.CookingFood.STime += int64(szTime[order.FoodType])
|
||||
gourmet.CookingFood.ETime += int64(szTime[order.FoodType])
|
||||
if zTime > 0 && gourmet.CookingFood.STime > zTime {
|
||||
gourmet.OrderCostTime = 0
|
||||
nextDay = true
|
||||
}
|
||||
if nextDay {
|
||||
nextDayTime += szTime[order.FoodType]
|
||||
}
|
||||
if curTime > costTime {
|
||||
// 转时间戳
|
||||
gourmet.CookingFood.FoodType = order.FoodType
|
||||
@ -134,12 +153,19 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if nextDay {
|
||||
gourmet.OrderCostTime += nextDayTime
|
||||
for _, order := range gourmet.Foods {
|
||||
if order.FoodCount == 0 {
|
||||
continue
|
||||
}
|
||||
gourmet.OrderCostTime += szTime[order.FoodType] * order.FoodCount
|
||||
}
|
||||
}
|
||||
// 保存信息
|
||||
mapData["foods"] = gourmet.Foods
|
||||
mapData["orderCostTime"] = gourmet.OrderCostTime
|
||||
mapData["cookingFood"] = gourmet.CookingFood // 正在做的
|
||||
this.module.ModifyGourmetData(uid, mapData)
|
||||
}
|
||||
|
||||
// 技能等级提高了 重新计算订单时间(只对订单中数据有影响)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"crypto/rand"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/utils"
|
||||
"math/big"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
@ -178,5 +179,25 @@ func (this *apiComp) StrengthenUpSkill(session comm.IUserSession, req *pb.HeroSt
|
||||
ChangeList = append(ChangeList, _hero)
|
||||
session.SendMsg(string(this.module.GetType()), "change", &pb.HeroChangePush{List: ChangeList})
|
||||
session.SendMsg(string(this.module.GetType()), StrengthenUpSkill, &pb.HeroStrengthenUpSkillResp{Hero: _hero})
|
||||
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype52, utils.ToInt32(_hero.HeroID), 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype53, 1)
|
||||
// 检查是不是满级技能
|
||||
maxLv := true
|
||||
for _, skill := range _hero.NormalSkill {
|
||||
skillMaxLv := this.module.configure.GetHeroSkillMaxLvConfig(uint32(skill.SkillID))
|
||||
if skill.SkillLv < skillMaxLv { // 找到没有满级的技能id
|
||||
maxLv = false
|
||||
}
|
||||
}
|
||||
if maxLv {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype54, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype57, 1)
|
||||
}
|
||||
cfg := this.module.configure.GetHero(_hero.HeroID)
|
||||
if cfg != nil {
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype55, cfg.Color, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype56, 1, 1, cfg.Job)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PagodaChalleng
|
||||
pagoda.Reward = seasonPagoda.Reward
|
||||
session.SendMsg(string(this.module.GetType()), PagodaChallengeResp, &pb.PagodaChallengeResp{Data: pagoda})
|
||||
}
|
||||
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype58, 1)
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype59, pagoda.PagodaId)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user