78 lines
2.4 KiB
Go
78 lines
2.4 KiB
Go
package wtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) BattleFinishCheck(session comm.IUserSession, req *pb.WTaskBattleFinishReq) (errdata *pb.ErrorData) {
|
|
if req.BattleConfId == 0 || req.Report == nil {
|
|
this.module.Error("世界任务战斗开始参数错误",
|
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
|
log.Field{Key: "params", Value: req.String()},
|
|
)
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "BattleConfId is 0 or Report is null",
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// /获取系统公告
|
|
func (this *apiComp) BattleFinish(session comm.IUserSession, req *pb.WTaskBattleFinishReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameWorldBattleData
|
|
err error
|
|
isWin bool
|
|
)
|
|
if errdata = this.BattleFinishCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getWorldtaskBattleById(req.BattleConfId); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if errdata, isWin = this.module.modelBattle.CheckBattleReport(session, req.Report); errdata == nil {
|
|
return
|
|
}
|
|
|
|
if isWin {
|
|
if conf.Carexe > 0 {
|
|
if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 {
|
|
for _, v := range req.Report.Info.Redflist[0].Team {
|
|
if !v.Ishelp { // 助战英雄不加经验
|
|
this.module.ModuleHero.AddHeroExp(session, v.Oid, conf.Carexe)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if errdata = this.module.DispenseRes(session, []*cfg.Gameatn{conf.Playexp}, true); errdata != nil {
|
|
this.module.Error("世界任务战斗玩家经验结算",
|
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
|
log.Field{Key: "playerExp", Value: conf.Playexp},
|
|
)
|
|
return
|
|
} else {
|
|
//触发任务
|
|
go this.module.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype70, 1, req.BattleConfId))
|
|
}
|
|
} else {
|
|
this.module.Error("世界任务战斗失败",
|
|
log.Field{Key: "uid", Value: session.GetUserId()},
|
|
log.Field{Key: "isWin", Value: isWin},
|
|
)
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "battlefinish", &pb.WTaskBattleFinishResp{BattleConfId: req.BattleConfId})
|
|
return
|
|
}
|