数据校验
This commit is contained in:
parent
ac247bc78b
commit
ab819cec6a
@ -3,6 +3,7 @@ package viking
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -37,11 +38,11 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量
|
||||
if amount <= 0 { // 有没有挑战次数
|
||||
if code = this.module.CheckRes(session, []*cfg.Gameatn{costRes}); code != pb.ErrorCode_Success {
|
||||
code = pb.ErrorCode_VikingMaxChallengeCount
|
||||
return
|
||||
}
|
||||
|
||||
cfgData := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty)
|
||||
if cfgData == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
|
@ -81,13 +81,13 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
if code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
|
||||
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
||||
code, bWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||
if !bWin { // 战斗失败 直接返回
|
||||
return
|
||||
}
|
||||
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
|
||||
code, bWin = this.module.battle.CheckBattleReport(session, req.Report)
|
||||
// 校验门票数量够不够
|
||||
|
||||
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
@ -96,6 +96,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
|
||||
if conf != nil {
|
||||
if amount < conf.VikingNum {
|
||||
viking.RecoveryTime = configure.Now().Unix()
|
||||
mapData["recoveryTime"] = viking.RecoveryTime
|
||||
}
|
||||
}
|
||||
this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, viking, req.Report)
|
||||
|
@ -38,7 +38,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
||||
if !utils.IsToday(list.CTime) {
|
||||
list.CTime = configure.Now().Unix()
|
||||
list.BuyCount = 0
|
||||
|
||||
mapData["cTime"] = list.CTime
|
||||
mapData["buyCount"] = list.BuyCount
|
||||
|
||||
@ -49,7 +48,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
}
|
||||
costRes := this.module.configure.GetGlobalConf().VikingExpeditionCos
|
||||
costRes := conf.VikingExpeditionCos
|
||||
if costRes == nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
@ -57,7 +56,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
||||
amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量
|
||||
curCount = amount
|
||||
// 道具上限
|
||||
if amount != conf.VikingNum {
|
||||
if amount < conf.VikingNum {
|
||||
if list.RecoveryTime == 0 {
|
||||
list.RecoveryTime = configure.Now().Unix()
|
||||
}
|
||||
@ -72,6 +71,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
||||
list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间
|
||||
}
|
||||
addCount := curCount - amount
|
||||
if addCount > 0 {
|
||||
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
|
||||
A: "item",
|
||||
T: ticketId,
|
||||
@ -79,6 +79,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
|
||||
}}, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
list.RecoveryTime = 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user