diff --git a/comm/const.go b/comm/const.go index a7ff56e81..36d92959f 100644 --- a/comm/const.go +++ b/comm/const.go @@ -62,6 +62,7 @@ const ( ModuleLinestory core.M_Modules = "linestory" //支线剧情 ModuleBattle core.M_Modules = "battle" //战斗 ModuleLibrary core.M_Modules = "library" // + ) //数据表名定义处 diff --git a/comm/imodule.go b/comm/imodule.go index 3953a0657..5d588d99f 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -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) + } ) diff --git a/modules/gm/module.go b/modules/gm/module.go index 6f9def8cd..fc0809ba2 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -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 +} diff --git a/modules/modulebase.go b/modules/modulebase.go index c61997f64..356e8c0ac 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -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 }