60 lines
1.4 KiB
Go
60 lines
1.4 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)
|
|
}
|
|
|
|
func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVEReq) (code pb.ErrorCode, resp *pb.BattlePVEResp) {
|
|
var record *pb.DBBattleRecord
|
|
if record, code = this.modelBattle.createpve(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
resp = &pb.BattlePVEResp{
|
|
Id: record.Id,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
}
|
|
return
|
|
}
|