diff --git a/modules/viking/api_sweep.go b/modules/viking/api_sweep.go index 2732d9aed..e9b5e2cf2 100644 --- a/modules/viking/api_sweep.go +++ b/modules/viking/api_sweep.go @@ -31,12 +31,13 @@ func (this *apiComp) Sweep(session comm.IUserSession, req *pb.VikingSweepReq) (e vikingCfg *cfg.GameVikingBossData user *pb.DBUser bWin bool // 战斗是否胜利 - atno []*pb.UserAtno // atno 类型 - atns []*pb.UserAssets //消耗 + rewardatno []*pb.UserAtno // atno 类型 + consumeatns []*pb.UserAssets // 消耗 changExp map[string]int32 heroupaward []*cfg.Gameatn reward []*cfg.Gameatn consume []*cfg.Gameatn + allconsume []*cfg.Gameatn err error result []*pb.VikingSweepResult @@ -137,21 +138,28 @@ func (this *apiComp) Sweep(session comm.IUserSession, req *pb.VikingSweepReq) (e } if !bWin { // 战斗失败了 直接返回 consume = append(consume, conf.LoseCost...) - consume = append(consume, this.module.ModuleUser.PsConvertExp(ps)) + reward = append(reward, this.module.ModuleUser.PsConvertExp(ps)) for _, v := range consume { - atns = append(atns, &pb.UserAssets{ + consumeatns = append(consumeatns, &pb.UserAssets{ A: v.A, T: v.T, N: v.N, }) } + //发放资源 + if errdata, rewardatno = this.module.DispenseAtno(session, reward, true); errdata != nil { + return + } result = append(result, &pb.VikingSweepResult{ Battleid: v.Info.Id, Iswin: false, - Consume: atns, + Consume: consumeatns, Rounds: v.Round, + Award: rewardatno, }) totalps += ps + allconsume = append(allconsume, consume...) + break } for _, v := range vikingCfg.PsConsume { @@ -189,40 +197,38 @@ func (this *apiComp) Sweep(session comm.IUserSession, req *pb.VikingSweepReq) (e } reward = append(reward, heroupaward...) } - //消耗资源 - if errdata = this.module.ConsumeRes(session, consume, true); errdata != nil { - return - } //发放资源 - if errdata, atno = this.module.DispenseAtno(session, reward, true); errdata != nil { + if errdata, rewardatno = this.module.DispenseAtno(session, reward, true); errdata != nil { return } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype73, 1, req.BossId, req.Difficulty)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype78, req.BossId, v.Costtime, req.Difficulty)) - tasks = append(tasks, comm.GetBuriedParam(comm.Rtype76, 1, req.BossId)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype77, 1, req.BossId, req.Difficulty)) - for _, v := range consume { - atns = append(atns, &pb.UserAssets{ + consumeatns = append(consumeatns, &pb.UserAssets{ A: v.A, T: v.T, N: v.N, }) } - result = append(result, &pb.VikingSweepResult{ Battleid: v.Info.Id, Iswin: true, Rounds: v.Round, - Consume: atns, - Award: atno, + Consume: consumeatns, + Award: rewardatno, Heroexp: changExp, }) + allconsume = append(allconsume, consume...) } tasks = append(tasks, comm.GetBuriedParam(comm.Rtype248, totalps, vikingCfg.Copytype)) - // tasks = append(tasks, comm.GetBuriedParam(comm.Rtype237, totalps)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype201, totalps)) + //消耗资源 + if errdata = this.module.ConsumeRes(session, allconsume, true); errdata != nil { + return + } + session.SendMsg(string(this.module.GetType()), VikingChallengeOverResp, &pb.VikingSweepResp{ Result: result, }) @@ -230,7 +236,7 @@ func (this *apiComp) Sweep(session comm.IUserSession, req *pb.VikingSweepReq) (e go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.chat.SendSysChatToWorld(session, comm.ChatSystem14, nil, req.BossId, req.Difficulty, user.Name) this.module.ModuleBuried.TriggerBuried(session, tasks...) - this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "VikingChallengeOverReq", atno) + this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "VikingChallengeOverReq", rewardatno) }) } return