67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package battle
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/modules"
|
|
"go_dreamfactory/pb"
|
|
)
|
|
|
|
/*
|
|
模块名:战斗模块
|
|
描述:处理游侠战斗相关业务
|
|
开发:李伟
|
|
*/
|
|
func NewModule() core.IModule {
|
|
m := new(Battle)
|
|
return m
|
|
}
|
|
|
|
type Battle struct {
|
|
modules.ModuleBase
|
|
api_comp *apiComp
|
|
configure *configureComp
|
|
modelBattle *modelBattleComp
|
|
}
|
|
|
|
//模块名
|
|
func (this *Battle) GetType() core.M_Modules {
|
|
return comm.ModuleBattle
|
|
}
|
|
|
|
//模块初始化接口 注册用户创建角色事件
|
|
func (this *Battle) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
|
|
err = this.ModuleBase.Init(service, module, options)
|
|
return
|
|
}
|
|
|
|
//装备组件
|
|
func (this *Battle) OnInstallComp() {
|
|
this.ModuleBase.OnInstallComp()
|
|
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
|
|
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
|
this.modelBattle = this.RegisterComp(new(modelBattleComp)).(*modelBattleComp)
|
|
}
|
|
|
|
//创建pve战斗
|
|
func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, record *pb.DBBattleRecord) {
|
|
if record, code = this.modelBattle.createpve(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
this.pushbattle(session, &pb.BattleStartPush{
|
|
Id: record.Id,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
})
|
|
return
|
|
}
|
|
|
|
//推送战斗开始数据
|
|
func (this *Battle) pushbattle(session comm.IUserSession, resp *pb.BattleStartPush) {
|
|
session.SendMsg(string(this.GetType()), "start", resp)
|
|
}
|