属性克隆

This commit is contained in:
meixiongfeng 2024-01-23 12:39:35 +08:00
parent 6e8a7ca1f4
commit 9e0e615b2f

View File

@ -36,6 +36,13 @@ func (this *ModelHero) Init(service core.IService, module core.IModule, comp cor
})
return
}
func (p *ModelHero) cloneTags(tags map[int32]int32) map[int32]int32 {
cloneTags := make(map[int32]int32)
for k, v := range tags {
cloneTags[k] = v
}
return cloneTags
}
// 计算英雄战力
func (this *ModelHero) calFigthValue(hero *pb.DBHero) (addValue int32, err error) {
@ -50,7 +57,18 @@ func (this *ModelHero) calFigthValue(hero *pb.DBHero) (addValue int32, err error
skillStar *cfg.GameFightingSkillStarData
)
tmpHero = new(pb.DBHero)
//tmpHero = this.copyPoint(hero)
*tmpHero = *hero // 克隆一个对象
// tmpHero.Property = make(map[int32]int32)
// tmpHero.AddProperty = make(map[int32]int32)
// tmpHero.JuexProperty = make(map[int32]int32)
// tmpHero.HoroscopeProperty = make(map[int32]int32)
// tmpHero.TalentProperty = make(map[int32]int32)
tmpHero.Property = this.cloneTags(hero.Property)
tmpHero.AddProperty = this.cloneTags(hero.AddProperty)
tmpHero.JuexProperty = this.cloneTags(hero.JuexProperty)
tmpHero.HoroscopeProperty = this.cloneTags(hero.HoroscopeProperty)
tmpHero.TalentProperty = this.cloneTags(hero.TalentProperty)
preValue = hero.Fightvalue
if heroCfg, err = this.module.configure.GetHeroConfig(tmpHero.HeroID); err != nil {
return