66 lines
1.8 KiB
Go
66 lines
1.8 KiB
Go
package wtask
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) BattleStartCheck(session comm.IUserSession, req *pb.WTaskBattleStartReq) (errdata *pb.ErrorData) {
|
|
if req.BattleConfId == 0 || req.Battle == 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",
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// /获取系统公告
|
|
func (this *apiComp) BattleStart(session comm.IUserSession, req *pb.WTaskBattleStartReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
record *pb.DBBattleRecord
|
|
)
|
|
if errdata = this.BattleStartCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
battleConf, err := this.module.configure.getWorldtaskBattleById(req.BattleConfId)
|
|
if err != nil || battleConf == nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if errdata, record = this.module.modelBattle.CreatePveBattle(session, &pb.BattlePVEReq{
|
|
Ptype: pb.PlayType_moonfantasy,
|
|
Format: req.Battle,
|
|
Mformat: battleConf.FormatList,
|
|
}); err != nil {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "battle", &pb.WTaskBattleStartResp{
|
|
BattleConfId: req.BattleConfId,
|
|
Info: &pb.BattleInfo{
|
|
Id: record.Id,
|
|
Rulesid: battleConf.BattleReadyID,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
Tasks: battleConf.EventList,
|
|
},
|
|
})
|
|
return
|
|
}
|