数据校验

This commit is contained in:
meixiongfeng 2022-11-28 19:56:16 +08:00
parent ac247bc78b
commit ab819cec6a
3 changed files with 17 additions and 14 deletions

View File

@ -3,6 +3,7 @@ package viking
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -37,11 +38,11 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量 if code = this.module.CheckRes(session, []*cfg.Gameatn{costRes}); code != pb.ErrorCode_Success {
if amount <= 0 { // 有没有挑战次数
code = pb.ErrorCode_VikingMaxChallengeCount code = pb.ErrorCode_VikingMaxChallengeCount
return return
} }
cfgData := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty) cfgData := this.module.configure.GetVikingBossConfigData(req.BossId, req.Difficulty)
if cfgData == nil { if cfgData == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound

View File

@ -81,13 +81,13 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
code, bWin = this.module.battle.CheckBattleReport(session, req.Report)
if !bWin { // 战斗失败 直接返回 if !bWin { // 战斗失败 直接返回
return return
} }
// 耗时校验 当前战斗胜利时间消耗小于之前刷新数据
code, bWin = this.module.battle.CheckBattleReport(session, req.Report)
// 校验门票数量够不够 // 校验门票数量够不够
if code = this.module.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success { if code = this.module.ConsumeRes(session, []*cfg.Gameatn{costRes}, true); code != pb.ErrorCode_Success {
return return
} }
@ -96,6 +96,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
if conf != nil { if conf != nil {
if amount < conf.VikingNum { if amount < conf.VikingNum {
viking.RecoveryTime = configure.Now().Unix() viking.RecoveryTime = configure.Now().Unix()
mapData["recoveryTime"] = viking.RecoveryTime
} }
} }
this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, viking, req.Report) this.module.CheckRank(session.GetUserId(), req.BossId, req.Difficulty, viking, req.Report)

View File

@ -38,7 +38,6 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
if !utils.IsToday(list.CTime) { if !utils.IsToday(list.CTime) {
list.CTime = configure.Now().Unix() list.CTime = configure.Now().Unix()
list.BuyCount = 0 list.BuyCount = 0
mapData["cTime"] = list.CTime mapData["cTime"] = list.CTime
mapData["buyCount"] = list.BuyCount mapData["buyCount"] = list.BuyCount
@ -49,7 +48,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return return
} }
costRes := this.module.configure.GetGlobalConf().VikingExpeditionCos costRes := conf.VikingExpeditionCos
if costRes == nil { if costRes == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return 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)) // 获取当前数量 amount := int32(this.module.ModuleItems.QueryItemAmount(session.GetUserId(), costRes.T)) // 获取当前数量
curCount = amount curCount = amount
// 道具上限 // 道具上限
if amount != conf.VikingNum { if amount < conf.VikingNum {
if list.RecoveryTime == 0 { if list.RecoveryTime == 0 {
list.RecoveryTime = configure.Now().Unix() 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) // 更新刷新时间 list.RecoveryTime += count * int64(conf.VikingExpeditionRecoveryTime*60) // 更新刷新时间
} }
addCount := curCount - amount addCount := curCount - amount
if addCount > 0 {
if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{ if code = this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{
A: "item", A: "item",
T: ticketId, T: ticketId,
@ -79,6 +79,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
}}, true); code != pb.ErrorCode_Success { }}, true); code != pb.ErrorCode_Success {
return return
} }
}
} else { } else {
list.RecoveryTime = 0 list.RecoveryTime = 0
} }