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 +}