远征购买挑战失败

This commit is contained in:
meixiongfeng 2022-12-09 22:08:07 +08:00
parent b798c860ad
commit 0618111487
2 changed files with 31 additions and 16 deletions

View File

@ -26,6 +26,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
mapData map[string]interface{}
szCostRes []*cfg.Gameatn // 购买累计消耗
curCount int32 // 当前门票数量
addCount int32 //获得数量
)
mapData = make(map[string]interface{}, 0)
code = this.BuyCheck(session, req)
@ -81,18 +82,16 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
}
}
if curCount-amount > 0 {
res := &cfg.Gameatn{
A: "item",
T: costRes.T,
N: curCount - amount,
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
return
}
addCount = curCount - amount
}
} else {
list.RecoveryTime = 0
}
addCount += req.Count
if amount+addCount > conf.VikingNum {
code = pb.ErrorCode_VikingBuyMaxCount
return
}
mapData["recoveryTime"] = list.RecoveryTime
for i := list.BuyCount + 1; i <= curByCount; i++ {
@ -121,6 +120,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
if code = this.module.ConsumeRes(session, sz, true); code != pb.ErrorCode_Success {
return
}
res := &cfg.Gameatn{
A: "item",
T: costRes.T,
N: addCount,
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
return
}
list.BuyCount = curByCount
mapData["buyCount"] = curByCount
code = this.module.ModifyHuntingData(session.GetUserId(), mapData)

View File

@ -26,6 +26,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
mapData map[string]interface{}
curCount int32 // 当前门票数量
szcostRes []*cfg.Gameatn // 购买累计消耗
addCount int32 //获得数量
)
mapData = make(map[string]interface{}, 0)
code = this.BuyCheck(session, req)
@ -77,18 +78,17 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
}
}
if curCount-amount > 0 {
res := &cfg.Gameatn{
A: "item",
T: costRes.T,
N: curCount - amount,
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
return
}
addCount = curCount - amount
}
} else {
list.RecoveryTime = 0
}
addCount += req.Count
if amount+addCount > conf.VikingNum {
code = pb.ErrorCode_VikingBuyMaxCount
return
}
mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间
curByCount += req.Count // 当前需要购买的数量
@ -123,6 +123,14 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
if code = this.module.ConsumeRes(session, sz, true); code != pb.ErrorCode_Success {
return
}
res := &cfg.Gameatn{
A: "item",
T: costRes.T,
N: addCount,
}
if code = this.module.DispenseRes(session, []*cfg.Gameatn{res}, true); code != pb.ErrorCode_Success {
return
}
list.BuyCount = curByCount
mapData["buyCount"] = curByCount
code = this.module.ModifyVikingData(session.GetUserId(), mapData)