Module:Item stats

local p = {} local Cargo = mw.ext.cargo local Expr = mw.ext.ParserFunctions.expr local Calc = require("Module:Calculate")._main local data = mw.loadData('Module:Attribute bonuses/data')

local i18n = { constructing = "constructing...", }

-- p.constructing = true

local MIXED = "MIXED" local PERCENT = "PERCENT" local FLAT = "FLAT" local UNKNOWN = "UNKNOWN"

local property = { "bonus_strength", "bonus_agility", "bonus_intelligence", "bonus_attack_damage", "bonus_health", "bonus_health_regen", "bonus_magic_resistance", "bonus_armor", "bonus_attack_speed", "bonus_movement_speed_percent", "bonus_mana", "bonus_mana_regen", "bonus_spell_damage", "title", }

function p.result( frame ) if p.constructing then return i18n.constructing end local page = frame:getParent.args[1] or mw.title.getCurrentTitle.text local Unique1 = frame:getParent.args["Unique1"]

local Contains = function(sz, character) return type(sz) == "string" and string.find(sz, character) and true end local ContainsSlash = function(sz) return Contains(sz, "/") end

local round = function(num, numDecimalPlaces) return math.floor(num * (10^(numDecimalPlaces or 0)) + 0.5) / (10^(numDecimalPlaces or 0)) end local round2 = function(num) return round(num, 2) end

local AttributeBonuses = function(param) return tostring(data[param] or 1) end

local AttributeID = function(param) return frame:expandTemplate{ title = 'Attribute ID', args = { param } } end

local ItemData = Cargo.query( 'items_bonustraits', table.concat(property, ", "), { where='_pageName="' .. page .. '"', groupBy='_pageID' } )[1]

local _2number = function(something) if (ContainsSlash(something)) then return something else return tonumber(something) end end

-- define_values local strength = _2number(ItemData[property[1]]) or 0 local agility = _2number(ItemData[property[2]]) or 0 local intelligence = _2number(ItemData[property[3]]) or 0

if (not ContainsSlash(strength) and not ContainsSlash(agility) and not ContainsSlash(intelligence) and (strength + agility + intelligence == 0)) then return "" end

local attack_damage = {strength, agility, intelligence}

for i,v in ipairs(attack_damage) do   if (v == 0) then attack_damage[i] = _2number(ItemData[property[4]]) or 0 elseif (ContainsSlash(_2number(ItemData[property[4]]) or 0)) then if (ContainsSlash(v)) then attack_damage[i] = Calc({ "v1+v2", ["v1"] = v, ["v2"] = ItemData[property[4]] }) else attack_damage[i] = Calc({ tostring(v) .. "+v1", ["v1"] = ItemData[property[4]] }) end else if (ContainsSlash(v)) then attack_damage[i] = Calc({ "v1+" .. tostring(_2number(ItemData[property[4]]) or 0), ["v1"] = v }) else attack_damage[i] = v + (_2number(ItemData[property[4]]) or 0) end end end

-- Strength local health = 0 local health_for_strength = 0 if (ContainsSlash(_2number(ItemData[property[5]]) or 0)) then if (ContainsSlash(strength)) then health = Calc({ "v1+v2*" .. AttributeBonuses("bonus health"), ["v1"] = ItemData[property[5]], ["v2"] = strength }) health_for_strength = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus health"), ["v1"] = ItemData[property[5]], ["v2"] = strength }) else health = Calc({ "v1+" .. tostring(strength) .. "*" .. AttributeBonuses("bonus health"), ["v1"] = ItemData[property[5]] }) health_for_strength = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(strength) .. "*" .. AttributeBonuses("bonus health"), ["v1"] = ItemData[property[5]] }) end else if (ContainsSlash(strength)) then health = Calc({ tostring(_2number(ItemData[property[5]]) or 0) .. "+v1*" .. AttributeBonuses("bonus health"), ["v1"] = strength }) health_for_strength = Calc({ tostring(_2number(ItemData[property[5]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus health"), ["v1"] = strength }) else health = (_2number(ItemData[property[5]]) or 0) + strength * (AttributeBonuses("bonus health") or 0) health_for_strength = (_2number(ItemData[property[5]]) or 0) + AttributeBonuses("primary attribute multiplier") * strength * (AttributeBonuses("bonus health") or 0) end end

local health_regeneration_flag = FLAT local health_regeneration = 0 local health_regeneration_for_strength = 0 if (ContainsSlash(_2number(ItemData[property[6]]) or 0)) then if (ContainsSlash(strength)) then health_regeneration = Calc({ "v1+v2*" .. AttributeBonuses("bonus health regeneration flat"), ["v1"] = ItemData[property[6]], ["v2"] = strength }) health_regeneration_for_strength = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus health regeneration flat"), ["v1"] = ItemData[property[6]], ["v2"] = strength }) else health_regeneration = Calc({ "v1+" .. tostring(strength) .. "*" .. AttributeBonuses("bonus health regeneration flat"), ["v1"] = ItemData[property[6]] }) health_regeneration_for_strength = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(strength) .. "*" .. AttributeBonuses("bonus health regeneration flat"), ["v1"] = ItemData[property[6]] }) end else if (ContainsSlash(strength)) then health_regeneration = Calc({ tostring(_2number(ItemData[property[6]]) or 0) .. "+v1*" .. AttributeBonuses("bonus health regeneration flat"), ["v1"] = strength }) health_regeneration_for_strength = Calc({ tostring(_2number(ItemData[property[6]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus health regeneration flat"), ["v1"] = strength }) else health_regeneration = (_2number(ItemData[property[6]]) or 0) + strength * (AttributeBonuses("bonus health regeneration flat") or 0) health_regeneration_for_strength = (_2number(ItemData[property[6]]) or 0) + AttributeBonuses("primary attribute multiplier") * strength * (AttributeBonuses("bonus health regeneration flat") or 0) end end

local magic_resistance = (_2number(ItemData[property[7]]) or 0) * 0.01 local magic_resistance_for_strength = (_2number(ItemData[property[7]]) or 0) * 0.01

-- if (ContainsSlash(_2number(ItemData[property[7]]) or 0)) then --  if (ContainsSlash(strength)) then --    magic_resistance = Calc({ "1-(1-v1*0.01)*(1-v2*" .. AttributeBonuses("bonus magic resistance") .. "*0.01)", ["v1"] = ItemData[property[7]], ["v2"] = strength }) --    magic_resistance_for_strength = Calc({ "1-(1-v1*0.01)*(1-" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus magic resistance") .. "*0.01)", ["v1"] = ItemData[property[7]], ["v2"] = strength }) --  else --    magic_resistance = Calc({ "1-(1-v1*0.01)*(1-" .. tostring(strength) .. "*" .. AttributeBonuses("bonus magic resistance") .. "*0.01)", ["v1"] = ItemData[property[7]] }) --    magic_resistance_for_strength = Calc({ "1-(1-v1*0.01)*(1-" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(strength) .. "*" .. AttributeBonuses("bonus magic resistance") .. "*0.01)", ["v1"] = ItemData[property[7]] }) --  end -- else --  if (ContainsSlash(strength)) then --    magic_resistance = Calc({ "1-(1-" .. tostring(_2number(ItemData[property[7]]) or 0) .. "*0.01)*(1-v1*" .. AttributeBonuses("bonus magic resistance") .. "*0.01)", ["v1"] = strength }) --    magic_resistance_for_strength = Calc({ "1-(1-" .. tostring(_2number(ItemData[property[7]]) or 0) .. "*0.01)*(1-" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus magic resistance") .. "*0.01)", ["v1"] = strength }) --  else --    magic_resistance = 1 - (1 - ((_2number(ItemData[property[7]]) or 0) * 0.01)) * (1 - strength * (AttributeBonuses("bonus magic resistance") or 0) * 0.01) --    magic_resistance_for_strength = 1 - (1 - ((_2number(ItemData[property[7]]) or 0) * 0.01)) * (1 - AttributeBonuses("primary attribute multiplier") * strength * (AttributeBonuses("bonus magic resistance") or 0) * 0.01) --  end -- end

local attack_damage_for_strength = attack_damage[1]

-- Agility local armor = 0 local armor_for_agility = 0 if (ContainsSlash(_2number(ItemData[property[8]]) or 0)) then if (ContainsSlash(agility)) then armor = Calc({ "v1+v2*" .. AttributeBonuses("bonus armor"), ["v1"] = ItemData[property[8]], ["v2"] = agility }) armor_for_agility = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus armor"), ["v1"] = ItemData[property[8]], ["v2"] = agility }) else armor = Calc({ "v1+" .. tostring(agility) .. "*" .. AttributeBonuses("bonus armor"), ["v1"] = ItemData[property[8]] }) armor_for_agility = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(agility) .. "*" .. AttributeBonuses("bonus armor"), ["v1"] = ItemData[property[8]] }) end else if (ContainsSlash(agility)) then armor = Calc({ tostring(_2number(ItemData[property[8]]) or 0) .. "+v1*" .. AttributeBonuses("bonus armor"), ["v1"] = agility }) armor_for_agility = Calc({ tostring(_2number(ItemData[property[8]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus armor"), ["v1"] = agility }) else armor = (_2number(ItemData[property[8]]) or 0) + agility * (AttributeBonuses("bonus armor") or 0) armor_for_agility = (_2number(ItemData[property[8]]) or 0) + AttributeBonuses("primary attribute multiplier") * agility * (AttributeBonuses("bonus armor") or 0) end end

local attack_speed = 0 local attack_speed_for_agility = 0 if (ContainsSlash(_2number(ItemData[property[9]]) or 0)) then if (ContainsSlash(agility)) then attack_speed = Calc({ "v1+v2*" .. AttributeBonuses("bonus attack speed"), ["v1"] = ItemData[property[9]], ["v2"] = agility }) attack_speed_for_agility = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus attack speed"), ["v1"] = ItemData[property[9]], ["v2"] = agility }) else attack_speed = Calc({ "v1+" .. tostring(agility) .. "*" .. AttributeBonuses("bonus attack speed"), ["v1"] = ItemData[property[9]] }) attack_speed_for_agility = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(agility) .. "*" .. AttributeBonuses("bonus attack speed"), ["v1"] = ItemData[property[9]] }) end else if (ContainsSlash(agility)) then attack_speed = Calc({ tostring(_2number(ItemData[property[9]]) or 0) .. "+v1*" .. AttributeBonuses("bonus attack speed"), ["v1"] = agility }) attack_speed_for_agility = Calc({ tostring(_2number(ItemData[property[9]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus attack speed"), ["v1"] = agility }) else attack_speed = (_2number(ItemData[property[9]]) or 0) + agility * (AttributeBonuses("bonus attack speed") or 0) attack_speed_for_agility = (_2number(ItemData[property[9]]) or 0) + AttributeBonuses("primary attribute multiplier") * agility * (AttributeBonuses("bonus attack speed") or 0) end end

local movement_speed_percent = _2number(ItemData[property[10]]) or 0 local movement_speed_percent_for_agility = _2number(ItemData[property[10]]) or 0

-- if (ContainsSlash(_2number(ItemData[property[10]]) or 0)) then --  if (ContainsSlash(agility)) then --    movement_speed_percent = Calc({ "v1+v2*" .. AttributeBonuses("bonus movement speed"), ["v1"] = ItemData[property[10]], ["v2"] = agility }) --    movement_speed_percent_for_agility = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus movement speed"), ["v1"] = ItemData[property[10]], ["v2"] = agility }) --  else --    movement_speed_percent = Calc({ "v1+" .. tostring(agility) .. "*" .. AttributeBonuses("bonus movement speed"), ["v1"] = ItemData[property[10]] }) --    movement_speed_percent_for_agility = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(agility) .. "*" .. AttributeBonuses("bonus movement speed"), ["v1"] = ItemData[property[10]] }) --  end -- else --  if (ContainsSlash(agility)) then --    movement_speed_percent = Calc({ tostring(_2number(ItemData[property[10]]) or 0) .. "+v1*" .. AttributeBonuses("bonus movement speed"), ["v1"] = agility }) --    movement_speed_percent_for_agility = Calc({ tostring(_2number(ItemData[property[10]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus movement speed"), ["v1"] = agility }) --  else --    movement_speed_percent = (_2number(ItemData[property[10]]) or 0) + agility * (AttributeBonuses("bonus movement speed") or 0) --    movement_speed_percent_for_agility = (_2number(ItemData[property[10]]) or 0) + AttributeBonuses("primary attribute multiplier") * agility * (AttributeBonuses("bonus movement speed") or 0) --  end -- end

local attack_damage_for_agility = attack_damage[2]

-- Intelligence local mana = 0 local mana_for_intelligence = 0 if (ContainsSlash(_2number(ItemData[property[11]]) or 0)) then if (ContainsSlash(intelligence)) then mana = Calc({ "v1+v2*" .. AttributeBonuses("bonus mana"), ["v1"] = ItemData[property[11]], ["v2"] = intelligence }) mana_for_intelligence = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus mana"), ["v1"] = ItemData[property[11]], ["v2"] = intelligence }) else mana = Calc({ "v1+" .. tostring(intelligence) .. "*" .. AttributeBonuses("bonus mana"), ["v1"] = ItemData[property[11]] }) mana_for_intelligence = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(intelligence) .. "*" .. AttributeBonuses("bonus mana"), ["v1"] = ItemData[property[11]] }) end else if (ContainsSlash(intelligence)) then mana = Calc({ tostring(_2number(ItemData[property[11]]) or 0) .. "+v1*" .. AttributeBonuses("bonus mana"), ["v1"] = intelligence }) mana_for_intelligence = Calc({ tostring(_2number(ItemData[property[11]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus mana"), ["v1"] = intelligence }) else mana = (_2number(ItemData[property[11]]) or 0) + intelligence * (AttributeBonuses("bonus mana") or 0) mana_for_intelligence = (_2number(ItemData[property[11]]) or 0) + AttributeBonuses("primary attribute multiplier") * intelligence * (AttributeBonuses("bonus mana") or 0) end end

local mana_regeneration_flag = FLAT local mana_regeneration = 0 local mana_regeneration_for_intelligence = 0 if (ContainsSlash(_2number(ItemData[property[12]]) or 0)) then if (ContainsSlash(intelligence)) then mana_regeneration = Calc({ "v1+v2*" .. AttributeBonuses("bonus mana regeneration flat"), ["v1"] = ItemData[property[12]], ["v2"] = intelligence }) mana_regeneration_for_intelligence = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus mana regeneration flat"), ["v1"] = ItemData[property[12]], ["v2"] = intelligence }) else mana_regeneration = Calc({ "v1+" .. tostring(intelligence) .. "*" .. AttributeBonuses("bonus mana regeneration flat"), ["v1"] = ItemData[property[12]] }) mana_regeneration_for_intelligence = Calc({ "v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(intelligence) .. "*" .. AttributeBonuses("bonus mana regeneration flat"), ["v1"] = ItemData[property[12]] }) end else if (ContainsSlash(intelligence)) then mana_regeneration = Calc({ tostring(_2number(ItemData[property[12]]) or 0) .. "+v1*" .. AttributeBonuses("bonus mana regeneration flat"), ["v1"] = intelligence }) mana_regeneration_for_intelligence = Calc({ tostring(_2number(ItemData[property[12]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus mana regeneration flat"), ["v1"] = intelligence }) else mana_regeneration = (_2number(ItemData[property[12]]) or 0) + intelligence * (AttributeBonuses("bonus mana regeneration flat") or 0) mana_regeneration_for_intelligence = (_2number(ItemData[property[12]]) or 0) + AttributeBonuses("primary attribute multiplier") * intelligence * (AttributeBonuses("bonus mana regeneration flat") or 0) end end

local spell_damage = (_2number(ItemData[property[13]]) or 0) * 0.01 local spell_damage_for_intelligence = (_2number(ItemData[property[13]]) or 0) * 0.01

-- if (ContainsSlash(_2number(ItemData[property[13]]) or 0)) then --  if (ContainsSlash(intelligence)) then --    spell_damage = Calc({ "(v1+v2*" .. AttributeBonuses("bonus spell damage") .. ")*0.01", ["v1"] = ItemData[property[13]], ["v2"] = intelligence }) --    spell_damage_for_intelligence = Calc({ "(v1+" .. AttributeBonuses("primary attribute multiplier") .. "*v2*" .. AttributeBonuses("bonus spell damage") .. ")*0.01", ["v1"] = ItemData[property[13]], ["v2"] = intelligence }) --  else --    spell_damage = Calc({ "(v1+" .. tostring(intelligence) .. "*" .. AttributeBonuses("bonus spell damage") .. ")*0.01", ["v1"] = ItemData[property[13]] }) --    spell_damage_for_intelligence = Calc({ "(v1+" .. AttributeBonuses("primary attribute multiplier") .. "*" .. tostring(intelligence) .. "*" .. AttributeBonuses("bonus spell damage") .. ")*0.01", ["v1"] = ItemData[property[13]] }) --  end -- else --  if (ContainsSlash(intelligence)) then --    spell_damage = Calc({ "(" .. tostring(_2number(ItemData[property[13]]) or 0) .. "+v1*" .. AttributeBonuses("bonus spell damage") .. ")*0.01", ["v1"] = intelligence }) --    spell_damage_for_intelligence = Calc({ "(" .. tostring(_2number(ItemData[property[13]]) or 0) .. "+" .. AttributeBonuses("primary attribute multiplier") .. "*v1*" .. AttributeBonuses("bonus spell damage") .. ")*0.01", ["v1"] = intelligence }) --  else --    spell_damage = ((_2number(ItemData[property[13]]) or 0) + intelligence * (AttributeBonuses("bonus spell damage") or 0)) * 0.01 --    spell_damage_for_intelligence = ((_2number(ItemData[property[13]]) or 0) + AttributeBonuses("primary attribute multiplier") * intelligence * (AttributeBonuses("bonus spell damage") or 0)) * 0.01 --  end -- end

local attack_damage_for_intelligence = attack_damage[3] -- END define_values

-- showing_string -- General local szHealth = "" if (health ~= 0) then szHealth = tostring(health) .. " health" end

local szHealthRegeneration = "" if (health_regeneration ~= 0) then if (health_regeneration_flag == FLAT) then if (ContainsSlash(health_regeneration)) then szHealthRegeneration = Calc({ "v1 round2", ["v1"] = health_regeneration }) .. " health regen" else szHealthRegeneration = tostring(round2(health_regeneration)) .. " health regen" end end end

local szMagicResistance = "" if (magic_resistance ~= 0) then if (ContainsSlash(magic_resistance)) then szMagicResistance = Calc({ "v1 round4", ["v1"] = magic_resistance, "%" }) .. " magic resistance" else szMagicResistance = tostring(round2(magic_resistance * 100)) .. "% magic resistance" end end

local szArmor = "" if (armor ~= 0) then if (ContainsSlash(armor)) then szArmor = Calc({ "v1 round2", ["v1"] = armor }) .. " main armor" else szArmor = tostring(round2(armor)) .. " main armor" end end

local szAttackSpeed = "" if (attack_speed ~= 0) then szAttackSpeed = tostring(attack_speed) .. " attack speed" end

local szMovementSpeed = "" if (movement_speed_percent ~= 0) then if (ContainsSlash(movement_speed_percent)) then szMovementSpeed = Calc({ "v1 round4", ["v1"] = movement_speed_percent }) .. "% movement speed" else szMovementSpeed = tostring(round2(movement_speed_percent)) .. "% movement speed" end end

local szMana = "" if (mana ~= 0) then szMana = tostring(mana) .. " mana" end

local szManaRegeneration = "" if (mana_regeneration ~= 0) then if (mana_regeneration_flag == FLAT) then if (ContainsSlash(mana_regeneration)) then szManaRegeneration = Calc({ "v1 round2", ["v1"] = mana_regeneration }) .. " mana regen" else szManaRegeneration = tostring(round2(mana_regeneration)) .. " mana regen" end end end

local szSpellDamage = "" if (spell_damage ~= 0) then if (ContainsSlash(spell_damage)) then szSpellDamage = Calc({ "v1 round4", ["v1"] = spell_damage, "%" }) .. " spell damage" else szSpellDamage = tostring(round2(spell_damage * 100)) .. "% spell damage" end end

-- Special -- Strength local szHealthForStrength = "" if (health_for_strength ~= 0) then szHealthForStrength = tostring(health_for_strength) .. " health" end

local szHealthRegenerationForStrength = "" if (health_regeneration_for_strength ~= 0) then if (health_regeneration_flag == FLAT) then if (ContainsSlash(health_regeneration_for_strength)) then szHealthRegenerationForStrength = Calc({ "v1 round2", ["v1"] = health_regeneration_for_strength }) .. " health regen" else szHealthRegenerationForStrength = tostring(round2(health_regeneration_for_strength)) .. " health regen" end end end

local szMagicResistanceForStrength = "" if (magic_resistance_for_strength ~= 0) then if (ContainsSlash(magic_resistance_for_strength)) then szMagicResistanceForStrength = Calc({ "v1 round4", ["v1"] = magic_resistance_for_strength, "%" }) .. " magic resistance" else szMagicResistanceForStrength = tostring(round2(magic_resistance_for_strength * 100)) .. "% magic resistance" end end

local szStrengthTable = { szHealthForStrength, szHealthRegenerationForStrength, szMagicResistanceForStrength, szArmor, szAttackSpeed, szMovementSpeed, szMana, szManaRegeneration, szSpellDamage, }

-- Agility local szArmorForAgility = "" if (armor_for_agility ~= 0) then if (ContainsSlash(armor_for_agility)) then szArmorForAgility = Calc({ "v1 round2", ["v1"] = armor_for_agility }) .. " main armor" else szArmorForAgility = tostring(round2(armor_for_agility)) .. " main armor" end end

local szAttackSpeedForAgility = "" if (attack_speed_for_agility ~= 0) then szAttackSpeedForAgility = tostring(attack_speed_for_agility) .. " attack speed" end

local szMovementSpeedForAgility = "" if (movement_speed_percent_for_agility ~= 0) then if (ContainsSlash(movement_speed_percent_for_agility)) then szMovementSpeedForAgility = Calc({ "v1 round4", ["v1"] = movement_speed_percent_for_agility }) .. "% movement speed" else szMovementSpeedForAgility = tostring(round2(movement_speed_percent_for_agility)) .. "% movement speed" end end

local szAgilityTable = { szHealth, szHealthRegeneration, szMagicResistance, szArmorForAgility, szAttackSpeedForAgility, szMovementSpeedForAgility, szMana, szManaRegeneration, szSpellDamage, }

-- Intelligence local szManaForIntelligence = "" if (mana_for_intelligence ~= 0) then szManaForIntelligence = tostring(mana_for_intelligence) .. " mana" end

local szManaRegenerationForIntelligence = "" if (mana_regeneration_for_intelligence ~= 0) then if (mana_regeneration_flag == FLAT) then if (ContainsSlash(mana_regeneration_for_intelligence)) then szManaRegenerationForIntelligence = Calc({ "v1 round2", ["v1"] = mana_regeneration_for_intelligence }) .. " mana regen" else szManaRegenerationForIntelligence = tostring(round2(mana_regeneration_for_intelligence)) .. " mana regen" end end end

local szSpellDamageForIntelligence = "" if (spell_damage_for_intelligence ~= 0) then if (ContainsSlash(spell_damage_for_intelligence)) then szSpellDamageForIntelligence = Calc({ "v1 round4", ["v1"] = spell_damage_for_intelligence, "%" }) .. " spell damage" else szSpellDamageForIntelligence = tostring(round2(spell_damage_for_intelligence * 100)) .. "% spell damage" end end

local szIntelligenceTable = { szHealth, szHealthRegeneration, szMagicResistance, szArmor, szAttackSpeed, szMovementSpeed, szManaForIntelligence, szManaRegenerationForIntelligence, szSpellDamageForIntelligence, }

-- Damage local damage_flag = nil if (attack_damage_for_strength == 0) then szStrengthTable[10] = "" end if (attack_damage_for_strength ~= 0) then szStrengthTable[10] = tostring(attack_damage_for_strength) .. " "   if damage_flag ~= nil then szStrengthTable[10] = szStrengthTable[10] .. "attack damage" else szStrengthTable[10] = szStrengthTable[10] .. "attack damage" end damage_flag = not damage_flag end

if (attack_damage_for_agility == 0) then szAgilityTable[10] = "" end if (attack_damage_for_agility ~= 0) then szAgilityTable[10] = tostring(attack_damage_for_agility) .. " "   if damage_flag ~= nil then szAgilityTable[10] = szAgilityTable[10] .. "attack damage" else szAgilityTable[10] = szAgilityTable[10] .. "attack damage" end damage_flag = not damage_flag end

if (attack_damage_for_intelligence == 0) then szIntelligenceTable[10] = "" end if (attack_damage_for_intelligence ~= 0) then szIntelligenceTable[10] = tostring(attack_damage_for_intelligence) .. " "   if damage_flag ~= nil then szIntelligenceTable[10] = szIntelligenceTable[10] .. "attack damage" else szIntelligenceTable[10] = szIntelligenceTable[10] .. "attack damage" end damage_flag = not damage_flag end -- END showing_string

local iCount = 0 local iIndex = 0 -- counting for _,sz in ipairs(szStrengthTable) do   if sz ~= "" then iCount = iCount + 1 end end local szStrength = "* For " .. AttributeID("strength") .. " heroes, " .. (Unique1 or "it grants") .. " " for _,sz in ipairs(szStrengthTable) do    if (sz ~= "") then if (iIndex == 0) then szStrength = szStrength .. sz     elseif (iIndex == iCount - 1) then szStrength = szStrength .. " and " .. sz .. "."     else szStrength = szStrength .. ", " .. sz     end iIndex = iIndex + 1 end end if (iCount == 0) then szStrength = "" end iCount = 0 iIndex = 0

for _,sz in ipairs(szAgilityTable) do   if sz ~= "" then iCount = iCount + 1 end end local szAgility = "* For " .. AttributeID("agility") .. " heroes, " .. (Unique1 or "it grants") .. " " for _,sz in ipairs(szAgilityTable) do    if (sz ~= "") then if (iIndex == 0) then szAgility = szAgility .. sz     elseif (iIndex == iCount - 1) then szAgility = szAgility .. " and " .. sz .. "."     else szAgility = szAgility .. ", " .. sz     end iIndex = iIndex + 1 end end if (iCount == 0) then szAgility = "" end iCount = 0 iIndex = 0

for _,sz in ipairs(szIntelligenceTable) do   if sz ~= "" then iCount = iCount + 1 end end local szIntelligence = "* For " .. AttributeID("intelligence") .. " heroes, " .. (Unique1 or "it grants") .. " " for _,sz in ipairs(szIntelligenceTable) do    if (sz ~= "") then if (iIndex == 0) then szIntelligence = szIntelligence .. sz     elseif (iIndex == iCount - 1) then szIntelligence = szIntelligence .. " and " .. sz .. "."     else szIntelligence = szIntelligence .. ", " .. sz     end iIndex = iIndex + 1 end end if (iCount == 0) then szIntelligence = "" end -- END counting

-- combine local strings = {szStrength, szAgility, szIntelligence}

local szResult = "" for _,sz in ipairs(strings) do   if (sz ~= "") then if (szResult ~= "") then szResult = szResult .. "\n" .. sz     else szResult = szResult .. sz     end end end -- END combine return szResult end

return p