From 0fe2ef2d6298ed2f9544539d998ce4fb6bd0384a Mon Sep 17 00:00:00 2001 From: zhaocy Date: Fri, 1 Jul 2022 09:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=AF=E5=B1=9E=E6=80=A7=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hero/model_hero.go | 13 ++++++++++++- modules/hero/module.go | 11 +++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/modules/hero/model_hero.go b/modules/hero/model_hero.go index 150bf7a6b..3c84c5dfa 100644 --- a/modules/hero/model_hero.go +++ b/modules/hero/model_hero.go @@ -156,7 +156,7 @@ func (this *ModelHero) setEquipment(uid, heroId string, equipIds []string) pb.Er } //合并属性即属性值累加 -func (this *ModelHero) mergeProperty(uid, heroId string, data map[string]int32) { +func (this *ModelHero) mergeMainProperty(uid, heroId string, data map[string]int32) { hero := this.getOneHero(uid, heroId) if hero == nil { return @@ -167,6 +167,17 @@ func (this *ModelHero) mergeProperty(uid, heroId string, data map[string]int32) hero.Property[comm.PropertyDef] += data[comm.PropertyDef] } +//合并附加属性 +func (this *ModelHero) mergeAddProperty(uid, heroId string, data map[string]int32) { + hero := this.getOneHero(uid, heroId) + if hero == nil { + return + } + hero.AddProperty[comm.PropertyHp] += data[comm.PropertyHp] + hero.AddProperty[comm.PropertyAtk] += data[comm.PropertyAtk] + hero.AddProperty[comm.PropertyDef] += data[comm.PropertyDef] +} + //属性计算 - 暂时放在modelHero里实现 //英雄基础属性 + 英雄等级基础属性 * 英雄成长系数 + 英雄星级对应等级属性 * 英雄品质系数 func (this *ModelHero) PropertyCompute(uid, heroId string) map[string]int32 { diff --git a/modules/hero/module.go b/modules/hero/module.go index f16e9cde2..b053180c4 100644 --- a/modules/hero/module.go +++ b/modules/hero/module.go @@ -79,13 +79,20 @@ func (this *Hero) GetHero(uid, heroId string) (*pb.DBHero, pb.ErrorCode) { //佩戴装备 func (this *Hero) UpdateEquipment(hero *pb.DBHero, equip []*pb.DB_Equipment) (code pb.ErrorCode) { equipIds := make([]string, 4) - property := make(map[string]int32) + property := make(map[string]int32) //主属性 + addProperty := make(map[string]int32) //副属性 for _, v := range equip { equipIds = append(equipIds, v.Id) + //主属性 property[v.MainEntry.AttrName] = v.MainEntry.Value + //附加属性 + for _, v := range v.AdverbEntry { + addProperty[v.AttrName] = v.Value + } } - this.modelHero.mergeProperty(hero.Uid, hero.Id, property) + this.modelHero.mergeMainProperty(hero.Uid, hero.Id, property) + this.modelHero.mergeAddProperty(hero.Uid, hero.Id, addProperty) return this.modelHero.setEquipment(hero.Uid, hero.Id, equipIds) }