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 2、修改主线关卡进度:bingo:mapid,102(102代表关卡位置) 3、修改心魔塔进度:bingo:pataid,10(10代表层数) 4、修改玩家经验值:bingo:exp,1000(1000代表新增的经验值 // */ //参数校验 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 && (datas[0] == comm.AttrType || datas[0] == comm.ItemType || datas[0] == comm.HeroType || datas[0] == comm.EquipmentType) { num, err := strconv.Atoi(datas[2]) if err != nil { code = pb.ErrorCode_ReqParameterError return } code = this.module.DispenseRes(session, []*cfg.Gameatn{ // 添加资源 { 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 } } 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)) } } } //this.module.ModuleHero.GetSpecifiedHero(session.GetUserId(), heroid, star, lv) session.SendMsg(string(this.module.GetType()), "cmd", &pb.GMCmdResp{IsSucc: false}) return }