GM模块提供接口

This commit is contained in:
meixiongfeng 2022-09-19 10:41:41 +08:00
parent c20099a715
commit d50ed5dac7
4 changed files with 39 additions and 0 deletions

View File

@ -62,6 +62,7 @@ const (
ModuleLinestory core.M_Modules = "linestory" //支线剧情
ModuleBattle core.M_Modules = "battle" //战斗
ModuleLibrary core.M_Modules = "library" //
)
//数据表名定义处

View File

@ -157,4 +157,7 @@ type (
//校验战报
CheckBattleReport(session IUserSession, report *pb.BattleReport) (code pb.ErrorCode, iswin bool)
}
IGm interface {
CreateCmd(session IUserSession, cmd string) (code pb.ErrorCode)
}
)

View File

@ -4,6 +4,10 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"strconv"
"strings"
)
/*
@ -38,3 +42,33 @@ func (this *GM) OnInstallComp() {
this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp)
}
func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (code pb.ErrorCode) {
keys := strings.Split(cmd, ":")
if len(keys) == 2 {
if keys[0] == "bingo" {
datas := strings.Split(keys[1], ",")
if len(datas) == 3 {
num, err := strconv.Atoi(datas[2])
if err != nil {
code = pb.ErrorCode_ReqParameterError
return
}
code = this.DispenseRes(session, []*cfg.Gameatn{ // 添加资源
{
A: datas[0],
T: datas[1],
N: int32(num),
},
}, true)
if code == pb.ErrorCode_Success { // 成功直接返回
session.SendMsg(string(this.GetType()), "cmd", &pb.GMCmdResp{IsSucc: true})
return
}
}
}
}
code = pb.ErrorCode_ReqParameterError
session.SendMsg(string(this.GetType()), "cmd", &pb.GMCmdResp{IsSucc: false})
return
}

View File

@ -96,6 +96,7 @@ func (this *ModuleBase) Start() (err error) {
if module, err = this.service.GetModule(comm.ModuleSys); err != nil {
return
}
this.ModuleSys = module.(comm.ISys)
return
}