副属性计算
This commit is contained in:
parent
7106ae27f4
commit
0fe2ef2d62
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user