55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package worldtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
// 战斗结束的请求
|
|
func (this *apiComp) BattlefinishCheck(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode) {
|
|
if req.BattleConfId == 0 || req.TaskId == 0 || req.Report == nil {
|
|
this.module.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
|
|
code = pb.ErrorCode_ReqParameterError
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) Battlefinish(session comm.IUserSession, req *pb.WorldtaskBattleFinishReq) (code pb.ErrorCode, data proto.Message) {
|
|
if code = this.BattlefinishCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
|
|
taskConf, err := this.module.configure.getWorldtaskById(req.TaskId)
|
|
if err != nil || taskConf == nil {
|
|
code = pb.ErrorCode_ConfigNoFound
|
|
return
|
|
}
|
|
|
|
rsp := &pb.WorldtaskBattleFinishResp{
|
|
TaskId: req.TaskId,
|
|
}
|
|
|
|
battleModule, err := this.module.service.GetModule(comm.ModuleBattle)
|
|
if err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
return
|
|
}
|
|
|
|
if ibattle, ok := battleModule.(comm.IBattle); ok {
|
|
var isWin bool
|
|
if code, isWin = ibattle.CheckBattleReport(session, req.Report); code == pb.ErrorCode_Success {
|
|
//触发任务
|
|
this.module.ModuleRtask.SendToRtask(session, comm.Rtype70, 1, req.BattleConfId)
|
|
}
|
|
this.module.Debug("校验战报", log.Fields{"uid": session.GetUserId(), "taskId": req.TaskId, "战斗结果": isWin})
|
|
}
|
|
|
|
if err := session.SendMsg(string(this.module.GetType()), WorldtaskBattleFinish, rsp); err != nil {
|
|
code = pb.ErrorCode_SystemError
|
|
}
|
|
return
|
|
}
|