This commit is contained in:
meixiongfeng 2022-09-21 19:40:56 +08:00
parent e68bbbe2d8
commit 25c0a21c35

View File

@ -23,6 +23,7 @@ func NewModule() core.IModule {
type GM struct { type GM struct {
modules.ModuleBase modules.ModuleBase
api_comp *apiComp api_comp *apiComp
service core.IService
} }
//模块名 //模块名
@ -33,6 +34,7 @@ func (this *GM) GetType() core.M_Modules {
//模块初始化接口 注册用户创建角色事件 //模块初始化接口 注册用户创建角色事件
func (this *GM) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *GM) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service
return return
} }
@ -49,7 +51,8 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
if len(keys) == 2 { if len(keys) == 2 {
if keys[0] == "bingo" { if keys[0] == "bingo" {
datas := strings.Split(keys[1], ",") datas := strings.Split(keys[1], ",")
if len(datas) == 3 { if len(datas) == 3 && (datas[0] == comm.AttrType || datas[0] == comm.ItemType ||
datas[0] == comm.HeroType || datas[0] == comm.EquipmentType) {
num, err := strconv.Atoi(datas[2]) num, err := strconv.Atoi(datas[2])
if err != nil { if err != nil {
code = pb.ErrorCode_ReqParameterError code = pb.ErrorCode_ReqParameterError
@ -62,6 +65,32 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorC
N: int32(num), N: int32(num),
}, },
}, true) }, true)
if code == pb.ErrorCode_Success { // 成功直接返回
session.SendMsg(string(this.GetType()), "cmd", &pb.GMCmdResp{IsSucc: true})
return
}
} else if len(datas) == 2 && (datas[0] == "mapid") {
module1, err := this.service.GetModule(comm.ModuleMainline)
if err != nil {
return
}
num, err := strconv.Atoi(datas[1])
if err != nil {
code = pb.ErrorCode_ReqParameterError
return
}
code = module1.(comm.IMainline).ModifyMainlineData(session.GetUserId(), int32(num))
} else if len(datas) == 2 && (datas[0] == "pataid") {
module1, err := this.service.GetModule(comm.ModulePagoda)
if err != nil {
return
}
num, err := strconv.Atoi(datas[1])
if err != nil {
code = pb.ErrorCode_ReqParameterError
return
}
code = module1.(comm.IPagoda).ModifyPagodaFloor(session, int32(num))
} }
} }
} }