|
|
|
@ -35,7 +35,7 @@ type Battle struct {
|
|
|
|
|
clientmgr *battleClientMgrComp //c#战斗客户端端管理
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//模块名
|
|
|
|
|
// 模块名
|
|
|
|
|
func (this *Battle) GetType() core.M_Modules {
|
|
|
|
|
return comm.ModuleBattle
|
|
|
|
|
}
|
|
|
|
@ -44,7 +44,7 @@ func (this *Battle) NewOptions() (options core.IModuleOptions) {
|
|
|
|
|
return new(Options)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//模块初始化接口 注册用户创建角色事件
|
|
|
|
|
// 模块初始化接口 注册用户创建角色事件
|
|
|
|
|
func (this *Battle) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
|
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
|
|
|
this.service = service.(base.IRPCXService)
|
|
|
|
@ -71,7 +71,7 @@ func (this *Battle) Start() (err error) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//装备组件
|
|
|
|
|
// 装备组件
|
|
|
|
|
func (this *Battle) OnInstallComp() {
|
|
|
|
|
this.ModuleBase.OnInstallComp()
|
|
|
|
|
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
|
|
@ -80,7 +80,7 @@ func (this *Battle) OnInstallComp() {
|
|
|
|
|
this.clientmgr = this.RegisterComp(new(battleClientMgrComp)).(*battleClientMgrComp)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询战斗记录
|
|
|
|
|
// 查询战斗记录
|
|
|
|
|
func (this *Battle) QueryBattleRecord(oid string) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var err error
|
|
|
|
|
if record, err = this.modelBattle.queryrecord(oid); err != nil {
|
|
|
|
@ -93,7 +93,7 @@ func (this *Battle) QueryBattleRecord(oid string) (errdata *pb.ErrorData, record
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建pve战斗
|
|
|
|
|
// 创建pve战斗
|
|
|
|
|
func (this *Battle) CreateEveBattle(session comm.IUserSession, req *pb.BattleEVEReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var (
|
|
|
|
|
conn *db.DBConn
|
|
|
|
@ -120,7 +120,7 @@ func (this *Battle) CreateEveBattle(session comm.IUserSession, req *pb.BattleEVE
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建pve战斗
|
|
|
|
|
// 创建pve战斗
|
|
|
|
|
func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVEReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var (
|
|
|
|
|
conn *db.DBConn
|
|
|
|
@ -153,8 +153,10 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
|
|
|
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var flag bool
|
|
|
|
|
for _, v := range req.Format.Friendformat {
|
|
|
|
|
if v != "" {
|
|
|
|
|
flag = true
|
|
|
|
|
// this.ModuleBuried.SendToRtask(session, comm.Rtype108, 1)
|
|
|
|
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype108, 1))
|
|
|
|
|
break
|
|
|
|
@ -164,13 +166,13 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE
|
|
|
|
|
if record, errdata = this.modelBattle.createpve(session, conn, pb.BattleType_pve, req); errdata != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if req.Format.Friendformat != nil {
|
|
|
|
|
if flag {
|
|
|
|
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype12, 1))
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建pve战斗
|
|
|
|
|
// 创建pve战斗
|
|
|
|
|
func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVBReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var (
|
|
|
|
|
conn *db.DBConn
|
|
|
|
@ -203,7 +205,7 @@ func (this *Battle) CreatePvbBattle(session comm.IUserSession, req *pb.BattlePVB
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建pve战斗
|
|
|
|
|
// 创建pve战斗
|
|
|
|
|
func (this *Battle) CreatePvpBattle(session comm.IUserSession, req *pb.BattlePVPReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var (
|
|
|
|
|
conn *db.DBConn
|
|
|
|
@ -229,7 +231,7 @@ func (this *Battle) CreatePvpBattle(session comm.IUserSession, req *pb.BattlePVP
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//只有跨服环境下才可使用
|
|
|
|
|
// 只有跨服环境下才可使用
|
|
|
|
|
func (this *Battle) CreateRtPvpBattle(req *pb.BattleRTPVPReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var (
|
|
|
|
|
redmodel *db.DBModel
|
|
|
|
@ -265,7 +267,7 @@ func (this *Battle) CreateRtPvpBattle(req *pb.BattleRTPVPReq) (errdata *pb.Error
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建连续战斗
|
|
|
|
|
// 创建连续战斗
|
|
|
|
|
func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLPVEReq) (errdata *pb.ErrorData, record *pb.DBBattleRecord) {
|
|
|
|
|
var (
|
|
|
|
|
conn *db.DBConn
|
|
|
|
@ -298,8 +300,10 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
|
|
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var flag bool
|
|
|
|
|
for _, v := range req.Format.Friendformat {
|
|
|
|
|
if v != "" {
|
|
|
|
|
flag = true
|
|
|
|
|
// this.ModuleBuried.SendToRtask(session, comm.Rtype108, 1)
|
|
|
|
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype108, 1))
|
|
|
|
|
break
|
|
|
|
@ -309,19 +313,19 @@ func (this *Battle) CreateLPVEBattle(session comm.IUserSession, req *pb.BattleLP
|
|
|
|
|
if record, errdata = this.modelBattle.createlpve(session, conn, pb.BattleType_lpev, req); errdata != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if req.Format.Friendformat != nil {
|
|
|
|
|
if flag {
|
|
|
|
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype12, 1))
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///创建角色列表 更具Format表格
|
|
|
|
|
// /创建角色列表 更具Format表格
|
|
|
|
|
func (this *Battle) CreateRolesByFormat(fid int32) (captain int32, roles []*pb.BattleRole, errdata *pb.ErrorData) {
|
|
|
|
|
captain, roles, errdata = this.modelBattle.createMasterRoles(2, 0, fid)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///创建角色列表 更具英雄列表
|
|
|
|
|
// /创建角色列表 更具英雄列表
|
|
|
|
|
func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRole, errdata *pb.ErrorData) {
|
|
|
|
|
roles = make([]*pb.BattleRole, len(heros))
|
|
|
|
|
for i, v := range heros {
|
|
|
|
@ -334,7 +338,7 @@ func (this *Battle) CreateRolesByHeros(heros []*pb.DBHero) (roles []*pb.BattleRo
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///获取战斗详情
|
|
|
|
|
// /获取战斗详情
|
|
|
|
|
func (this *Battle) GetBattleInfo(req *pb.BattleGetInfoReq) (errdata *pb.ErrorData, resp *pb.BattleGetInfoResp) {
|
|
|
|
|
this.Debug("GetBattleInfo", log.Field{Key: "req", Value: req})
|
|
|
|
|
var (
|
|
|
|
@ -352,7 +356,7 @@ func (this *Battle) GetBattleInfo(req *pb.BattleGetInfoReq) (errdata *pb.ErrorDa
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建战斗服务
|
|
|
|
|
// 创建战斗服务
|
|
|
|
|
func (this *Battle) CreateBattleServer(req *pb.BattleInfo) (errdata *pb.ErrorData) {
|
|
|
|
|
this.Debug("CreateBattleServer", log.Field{Key: "req", Value: req})
|
|
|
|
|
var (
|
|
|
|
@ -400,7 +404,7 @@ func (this *Battle) InCmdBattle(req *pb.BattleInCmdReq) (errdata *pb.ErrorData)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//pvp认输
|
|
|
|
|
// pvp认输
|
|
|
|
|
func (this *Battle) ConcedeBattle(req *pb.BattleConcedeReq) (errdata *pb.ErrorData) {
|
|
|
|
|
var (
|
|
|
|
|
resp *pb.BattleConcedeResp
|
|
|
|
@ -422,7 +426,7 @@ func (this *Battle) ConcedeBattle(req *pb.BattleConcedeReq) (errdata *pb.ErrorDa
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验战报是否成功
|
|
|
|
|
// 校验战报是否成功
|
|
|
|
|
func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.BattleReport) (errdata *pb.ErrorData, iswin bool) {
|
|
|
|
|
var (
|
|
|
|
|
reply *pb.BattleCheckResults
|
|
|
|
@ -459,5 +463,10 @@ func (this *Battle) CheckBattleReport(session comm.IUserSession, report *pb.Batt
|
|
|
|
|
// this.ModuleBuried.SendToRtask(session, comm.Rtype157, int32(report.Info.Ptype), v)
|
|
|
|
|
go this.ModuleBuried.TriggerBuried(session.GetUserId(), comm.GetBuriedParam(comm.Rtype157, int32(report.Info.Ptype), v))
|
|
|
|
|
}
|
|
|
|
|
return nil, true
|
|
|
|
|
|
|
|
|
|
if (report.WinSide == 1 && report.Info.RedCompId == session.GetUserId()) || (report.WinSide == 2 && report.Info.BlueCompId == session.GetUserId()) {
|
|
|
|
|
return nil, true
|
|
|
|
|
} else {
|
|
|
|
|
return nil, false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|