70 lines
1.9 KiB
Go
70 lines
1.9 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) BattleEventCheck(session comm.IUserSession, req *pb.WTaskBattleEventReq) (errdata *pb.ErrorData) {
|
|
if req.Group == 0 || req.Event == 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) BattleEvent(session comm.IUserSession, req *pb.WTaskBattleEventReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
conf *cfg.GameWorldRdData
|
|
record *pb.DBBattleRecord
|
|
err error
|
|
)
|
|
if errdata = this.BattleEventCheck(session, req); errdata != nil {
|
|
return
|
|
}
|
|
if conf, err = this.module.configure.getGameWorldRdData(req.Event); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ConfigNoFound,
|
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
|
|
if errdata, record = this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
|
Rulesid: conf.Battleready,
|
|
Ptype: pb.PlayType_rtask,
|
|
Format: req.Battle,
|
|
Mformat: []int32{conf.Battleid},
|
|
}); err != nil {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "battleevent", &pb.WTaskBattleEventResp{
|
|
Group: req.Group,
|
|
Event: req.Event,
|
|
Info: &pb.BattleInfo{
|
|
Id: record.Id,
|
|
Rulesid: conf.Battleready,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
Tasks: record.Tasks,
|
|
},
|
|
})
|
|
return
|
|
}
|