From e556db1c40af5ddda4579851f1b85054e01a5b44 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 22 Feb 2023 19:14:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=9B=BE=E9=89=B4=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=8F=91=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 11 ++++++----- comm/imodule.go | 4 ++++ modules/modulebase.go | 15 ++++++++++++++- modules/smithy/api_forgeequip.go | 20 ++++++++++---------- modules/smithy/module.go | 24 ++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/comm/core.go b/comm/core.go index c34fda2e0..815f324dc 100644 --- a/comm/core.go +++ b/comm/core.go @@ -26,11 +26,12 @@ type ISC_GateRouteComp interface { //游戏类资源类型 const ( - AttrType = "attr" //用户属性资源 例如货币 经验 之类的 - ItemType = "item" //道具物品资源 - HeroType = "hero" //卡片资源 例如英雄卡,检验卡 - EquipmentType = "equi" //武器资源 - VipType = "vip" //vip + AttrType = "attr" //用户属性资源 例如货币 经验 之类的 + ItemType = "item" //道具物品资源 + HeroType = "hero" //卡片资源 例如英雄卡,检验卡 + EquipmentType = "equi" //武器资源 + VipType = "vip" //vip + AtlasType = "atlas" // ) type Autogenerated struct { diff --git a/comm/imodule.go b/comm/imodule.go index 1767a9cee..1fbf94116 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -409,4 +409,8 @@ type ( //推送战斗结束 PvpFinishPush(battleId string) } + + ISmithy interface { + CheckActivateAtlasCollect(uid string, id string) (code pb.ErrorCode) + } ) diff --git a/modules/modulebase.go b/modules/modulebase.go index 632811a27..12adb0fec 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -38,6 +38,7 @@ type ModuleBase struct { ModuleRtask comm.IRtask //随机任务 ModuleSociaty comm.ISociaty //公会 ModulePrivilege comm.IPrivilege // 月卡 + ModuleSmithy comm.ISmithy // } //重构模块配置对象 @@ -114,6 +115,11 @@ func (this *ModuleBase) Start() (err error) { return } this.ModulePrivilege = module.(comm.IPrivilege) + + if module, err = this.service.GetModule(comm.ModuleSmithy); err != nil { + return + } + this.ModuleSmithy = module.(comm.ISmithy) return } @@ -378,12 +384,14 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat attrs map[string]int32 // 属性 equips map[string]uint32 // 装备 vip map[string]int32 // vip + atlas map[string]int32 // ) items = make(map[string]int32, 0) heros = make(map[string]int32, 0) attrs = make(map[string]int32, 0) equips = make(map[string]uint32, 0) vip = make(map[string]int32, 0) + atlas = make(map[string]int32, 0) for _, v := range res { switch v.A { @@ -425,7 +433,12 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat code, _ = this.ModulePrivilege.Delivery(session, k) this.Debugf("发放月卡资源: %v [%v]", k, code) } - + } + if len(atlas) > 0 { + for k := range atlas { + code = this.ModuleSmithy.CheckActivateAtlasCollect(session.GetUserId(), k) + this.Debugf("发放图鉴资源: %v [%v]", k, code) + } } return } diff --git a/modules/smithy/api_forgeequip.go b/modules/smithy/api_forgeequip.go index 685aa6fc5..499edb194 100644 --- a/modules/smithy/api_forgeequip.go +++ b/modules/smithy/api_forgeequip.go @@ -86,17 +86,12 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq // 熟练度减少的温度 t := this.module.modelStove.CheckTemperature(req.ReelId, stove.Data[req.ReelId].Lv) needTemperatureCos = reelcfg.TemperatureCos * (1000 - t) / 1000 - // 检查炉温 是否够 - if stove.Temperature < needTemperatureCos { - code = pb.ErrorCode_SmithyNoTemperature // 炉温不够 直接返回 - return - } if req.Lava > 0 { // 是否是熔岩打造 exemption := this.module.configure.GetGlobalConf().ExemptionTemperatureCos // 预计消耗温度 - raise_temperatureNum := this.module.configure.GetGlobalConf().ExemptionTemperatureCosNum - raise_temperatureNum = req.Lava * exemption.N - if needTemperatureCos > raise_temperatureNum { + exemption_TemperatureCosNum := this.module.configure.GetGlobalConf().ExemptionTemperatureCosNum + exemption_TemperatureCosNum = req.Lava * exemption_TemperatureCosNum + if needTemperatureCos > exemption_TemperatureCosNum { code = pb.ErrorCode_SmithyLackLava // 缺少熔岩 return } @@ -111,13 +106,18 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq } costRes = append(costRes, lavaCost) } else { + // 检查炉温 是否够 + if stove.Temperature < needTemperatureCos { + code = pb.ErrorCode_SmithyNoTemperature // 炉温不够 直接返回 + return + } stove.Temperature -= needTemperatureCos // 消耗温度 update["temperature"] = stove.Temperature } costRes = append(costRes, reelcfg.BasicCos...) - subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) - costRes = append(costRes, subAtn...) + // subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) + // costRes = append(costRes, subAtn...) if code = this.module.CheckRes(session, costRes); code != pb.ErrorCode_Success { return } diff --git a/modules/smithy/module.go b/modules/smithy/module.go index 485cd36aa..9eec80349 100644 --- a/modules/smithy/module.go +++ b/modules/smithy/module.go @@ -10,6 +10,7 @@ import ( "go_dreamfactory/lego/core" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" ) type Smithy struct { @@ -43,6 +44,7 @@ func (this *Smithy) OnInstallComp() { this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.modelTrade = this.RegisterComp(new(modelTrade)).(*modelTrade) this.modelStove = this.RegisterComp(new(modelStove)).(*modelStove) + this.modelAtlas = this.RegisterComp(new(modelAtlas)).(*modelAtlas) } // 接口信息 @@ -66,3 +68,25 @@ func (this *Smithy) SendRdTask(session comm.IUserSession, Items []*pb.UserAssets this.ModuleRtask.SendToRtask(session, comm.Rtype51, v, k) } } +func (this *Smithy) CheckActivateAtlasCollect(uid string, id string) (code pb.ErrorCode) { + atlasConf := this.configure.GetSmithyAtlasConf(id) + if atlasConf != nil && atlasConf.TypeId == 2 { + if list, err := this.modelAtlas.getSmithyAtlasList(uid); err == nil { + if _, ok := list.Collect[id]; !ok { + list.Collect[id] = &pb.CollectData{ + Id: id, + Score: atlasConf.AtlasScore, + Time: configure.Now().Unix(), + } + list.Score += atlasConf.AtlasScore + update := make(map[string]interface{}, 0) + update["collect"] = list.Collect + update["score"] = list.Score + this.modelAtlas.modifySmithyAtlasList(uid, update) // 更新分数信息 + return + } + } + } + code = pb.ErrorCode_SmithyNoFoundAtlas + return +} From 46d5d3b3fdb109d4cc4713ea976d2ff791e1d03d Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Thu, 23 Feb 2023 09:35:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=20?= =?UTF-8?q?=E9=98=B2=E6=AD=A2=E4=B8=8D=E6=B6=88=E8=80=97=E8=AF=A5=E9=81=93?= =?UTF-8?q?=E5=85=B7=20=E4=BD=86=E6=98=AF=E6=8A=80=E8=83=BD=E5=81=9A?= =?UTF-8?q?=E4=BA=86=E8=AF=A5=E9=81=93=E5=85=B7=E7=9A=84=E5=87=8F=E5=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/smithy/api_forgeequip.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/modules/smithy/api_forgeequip.go b/modules/smithy/api_forgeequip.go index 499edb194..4b92f4f31 100644 --- a/modules/smithy/api_forgeequip.go +++ b/modules/smithy/api_forgeequip.go @@ -116,8 +116,19 @@ func (this *apiComp) ForgeEquip(session comm.IUserSession, req *pb.SmithyForgeEq } costRes = append(costRes, reelcfg.BasicCos...) - // subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) - // costRes = append(costRes, subAtn...) + subAtn := this.module.modelStove.CheckForgeConsume(req.ReelId, stove.Data[req.ReelId].Lv) + //costRes = append(costRes, subAtn...) + // 异常处理 防止不消耗该道具 但是技能做了该道具的减免 + for _, v := range costRes { + for _, v1 := range subAtn { + if v.A == v1.A && v.T == v1.T { + v.N += v1.N + } + } + if v.N < 0 { + v.N = 0 + } + } if code = this.module.CheckRes(session, costRes); code != pb.ErrorCode_Success { return }