From 752ef2d4b12e9aeec35c6fe120f9123fd20f0a4a Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 9 Jun 2023 12:01:19 +0800 Subject: [PATCH] =?UTF-8?q?gm=20=E8=B7=B3=E8=BD=AC=E5=8A=9F=E5=A4=AB?= =?UTF-8?q?=E5=A4=A7=E5=B8=88=E5=A1=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/imodule.go | 2 +- modules/gm/api_cmd.go | 2 +- modules/gm/module.go | 19 ++++++++++++++----- modules/pagoda/comp_configure.go | 30 +++++++++++++++++++++++++++++- modules/pagoda/module.go | 29 ++++++++++++++++------------- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/comm/imodule.go b/comm/imodule.go index 279c2587d..81b734918 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -310,7 +310,7 @@ type ( } // 修改爬塔 IPagoda interface { - ModifyPagodaFloor(session IUserSession, level int32) (errdata *pb.ErrorData) + ModifyPagodaFloor(session IUserSession, d1 int32, d2 int32) (errdata *pb.ErrorData) CheckUserBasePagodaInfo(uid string) (data *pb.DBPagodaRecord) // 查询玩家最佳通关记录 // Check Rtype84 Rtype85 Rtype86 diff --git a/modules/gm/api_cmd.go b/modules/gm/api_cmd.go index c0eb332d8..1c8641b3a 100644 --- a/modules/gm/api_cmd.go +++ b/modules/gm/api_cmd.go @@ -11,7 +11,7 @@ import ( //bingo:equi,xxx,1 // xxx 装备id -3、修改心魔塔进度:bingo:pataid,10(10代表层数) +3、修改心魔塔进度:bingo:pataid,1,10(页签+层数) 4、修改玩家经验值:bingo:attr,exp,1000(1000代表新增的经验值 // diff --git a/modules/gm/module.go b/modules/gm/module.go index fc3062d51..6f214a319 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -94,12 +94,12 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er log.Field{Key: "T", Value: datas[1]}, log.Field{Key: "N", Value: int32(num)}, ) - } else if len(datas) == 2 && (datas[0] == "pataid") { + } else if len(datas) == 3 && (datas[0] == "pataid") { module1, err := this.service.GetModule(comm.ModulePagoda) if err != nil { return } - num, err := strconv.Atoi(datas[1]) + d1, err := strconv.Atoi(datas[1]) if err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_ReqParameterError, @@ -107,11 +107,20 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er } return } - errdata = module1.(comm.IPagoda).ModifyPagodaFloor(session, int32(num)) + d2, err := strconv.Atoi(datas[2]) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + } + return + } + errdata = module1.(comm.IPagoda).ModifyPagodaFloor(session, int32(d1), int32(d2)) this.Debug("使用bingo命令:uid = %s ", log.Field{Key: "uid", Value: session.GetUserId()}, - log.Field{Key: "0", Value: datas[0]}, - log.Field{Key: "N", Value: int32(num)}, + log.Field{Key: "p0", Value: datas[0]}, + log.Field{Key: "p1", Value: datas[1]}, + log.Field{Key: "p3", Value: datas[2]}, ) } else if len(datas) == 1 && (datas[0] == "Iamyoudad" || datas[0] == "iamyoudad") { var ( diff --git a/modules/pagoda/comp_configure.go b/modules/pagoda/comp_configure.go index 140bc1a70..7f75f6180 100644 --- a/modules/pagoda/comp_configure.go +++ b/modules/pagoda/comp_configure.go @@ -1,6 +1,7 @@ package pagoda import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/log" @@ -25,6 +26,7 @@ type configureComp struct { hlock sync.RWMutex _checkType map[int32][]*cfg.GamePassCheckData // key type + _mapPagoda map[int32]*cfg.GamePagodaData } //组件初始化接口 @@ -38,7 +40,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp this._checkType = make(map[int32][]*cfg.GamePassCheckData, 0) configure.RegisterConfigure(game_passcheck, cfg.NewGamePassCheck, this.LoadPassCheck) - + configure.RegisterConfigure(game_pagoda, cfg.NewGamePagoda, this.LoadPagoda) return } @@ -161,3 +163,29 @@ func (this *configureComp) GetPagodaConfigData(id int32) (data *cfg.GamePagodaDa err = comm.NewNotFoundConfErr(moduleName, game_pagoda, id) return } + +func (this *configureComp) LoadPagoda() { + var err error + if v, err := this.GetConfigure(game_pagoda); err == nil { + if configure, ok := v.(*cfg.GamePagoda); ok { + this._mapPagoda = make(map[int32]*cfg.GamePagodaData) + this.hlock.Lock() + defer this.hlock.Unlock() + for _, value := range configure.GetDataList() { + key := value.Tab<<16 + value.LayerNum + this._mapPagoda[key] = value + } + return + } + } + log.Errorf("get game_pagoda conf err:%v", err) + return +} + +func (this *configureComp) GetPagodaConfBytab(tab int32, ly int32) (data *cfg.GamePagoda, err error) { + if _, ok := this._mapPagoda[tab<<16+ly]; ok { + return + } + err = comm.NewNotFoundConfErr("pagoda", game_pagoda, fmt.Errorf("tab %d ,ly %d not found", tab, ly)) + return +} diff --git a/modules/pagoda/module.go b/modules/pagoda/module.go index e5796861a..d83d347e5 100644 --- a/modules/pagoda/module.go +++ b/modules/pagoda/module.go @@ -85,22 +85,25 @@ func (this *Pagoda) Start() (err error) { } // 给gm 调用修改爬塔层数 -func (this *Pagoda) ModifyPagodaFloor(session comm.IUserSession, level int32) (errdata *pb.ErrorData) { +func (this *Pagoda) ModifyPagodaFloor(session comm.IUserSession, d1 int32, d2 int32) (errdata *pb.ErrorData) { list, _ := this.modelPagoda.getPagodaList(session.GetUserId()) - if list != nil { - - list.PagodaId = level - mapData := make(map[string]interface{}, 0) - mapData["pagodaId"] = level - // 通关校验 - _, err := this.configure.GetPagodaConfigData(level + 1) - if err == nil { - list.Complete = true - mapData["complete"] = true + //参数校验 + _, err := this.configure.GetPagodaConfBytab(d1, d2) + if err != nil { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_ConfigNoFound, + Title: pb.ErrorCode_ConfigNoFound.ToString(), + Message: err.Error(), } - errdata = this.ModifyPagodaData(session.GetUserId(), mapData) - session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) + return } + list.Data[d1] = d2 + list.PagodaId = d2 + mapData := make(map[string]interface{}, 0) + mapData["data"] = list.Data + mapData["pagodaId"] = list.PagodaId + errdata = this.ModifyPagodaData(session.GetUserId(), mapData) + session.SendMsg(string(this.GetType()), PagodaGetListResp, &pb.PagodaGetListResp{Data: list}) return }