package gm import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "strconv" "strings" "google.golang.org/protobuf/proto" ) /* GM 在控制台输入的字符串类型 //bingo:item,10001,1 //bingo:attr,gold,1000000 */ //参数校验 func (this *apiComp) CmdCheck(session comm.IUserSession, req *pb.GMCmdReq) (code pb.ErrorCode) { if len(req.Cmod) == 0 { code = pb.ErrorCode_ReqParameterError } return } ///解析GM 指令 func (this *apiComp) Cmd(session comm.IUserSession, req *pb.GMCmdReq) (code pb.ErrorCode, data proto.Message) { if code = this.CmdCheck(session, req); code != pb.ErrorCode_Success { return } keys := strings.Split(req.Cmod, ":") 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.module.DispenseRes(session, []*cfg.Game_atn{ // 添加资源 { A: datas[0], T: datas[1], N: int32(num), }, }, true) if code == pb.ErrorCode_Success { // 成功直接返回 session.SendMsg(string(this.module.GetType()), "cmd", &pb.GMCmdResp{IsSucc: true}) return } } } } //this.module.ModuleHero.GetSpecifiedHero(session.GetUserId(), heroid, star, lv) session.SendMsg(string(this.module.GetType()), "cmd", &pb.GMCmdResp{IsSucc: false}) return }