--[[ HeroInfo的属性处理 ]] local HeroInfoPropertyUtil = {} local private = {} --按照索引对应,参照Proto的hero.proto中的HeroInfo local PropertyTable = { "heroId", "heroLevel", "starLevel", "starStage", "winNum", "fightNum", "exp", "rankId", "Gs", "attr", "isMagicWeaponActive", "magicWeaponActivePhase", "heroAdvanceLevel", "advanceEquipState", "equipInfos", "magicWeaponLevel", "magicWeaponStar", "jewelryInfos", "jewelryLevel", "horseInfo", "treasureInfo", "suitActiveInfo", "pictorialLevel", "curAppearanceId", "curWeaponAppearanceId", "lightEffectIds", "magicWeaponPictorialLevel", "curAttrAppearanceId", "curAttrWeaponAppearanceId", "StrengthenInfo", "equipStarSkillId", "equipStarReplaceSkillId", } --需要优化的协议,对于自定对结构,如果确实要更新为空,则会强设置一个值 local NeedOptimizeProperty = { equipInfos = 1, jewelryInfos = 1, jewelryLevel = 1, horseInfo = 1, treasureInfo = 1, suitActiveInfo = 1, StrengthenInfo = 1, } function HeroInfoPropertyUtil.CloneHeroInfoData(heroData) local copyData = {} for index, propertyName in ipairs(PropertyTable) do copyData[propertyName] = heroData[propertyName] end return copyData end function private.IsPropertyValueNotNil(propertyName, heroPropertyValue) if NeedOptimizeProperty[propertyName] then return IsProtoDataNotNil(heroPropertyValue) end return true end function HeroInfoPropertyUtil.UpdateHeroProperty(oldHero, newHero) for index, propertyName in ipairs(PropertyTable) do if private.IsPropertyValueNotNil(propertyName, newHero[propertyName]) then oldHero[propertyName] = newHero[propertyName] end end end return HeroInfoPropertyUtil