Module:Ability

local symbol = require( 'Module:Symbol' )._main local symbol_aghs = symbol({ 'Aghanim' }) local symbol_shard = symbol({ 'Aghshard' }) local symbol_tal = symbol({ 'Talent' }) local color = require( 'Module:Color' )._main local color_aghs = color({ 'cos_rare' }) local color_shard = color({ 'cos_developer' }) local color_tal = color({ 'cos_immortal' }) local getArgs = require( 'Module:Arguments' ).getArgs local p = {}

-- Implements the mechanics symbols in the header. function p.symbols(frame) local args = getArgs(frame, {   wrappers = {      'Template:Ability'    }  }) local default_size = '20px' local symbols = {} if args['oncastproc'] then table.insert( symbols, symbol({ 'on cast proc', size=default_size }) ) end if args['rootdisables'] then table.insert( symbols, symbol({ 'root', args['rootdisables'], size=default_size }) ) end if args['illusionuse'] then table.insert( symbols, symbol({ 'illusion', args['illusionuse'], size=default_size }) ) end if args['disjointable'] then table.insert( symbols, symbol({ 'disjoint', args['disjointable'], size=default_size }) ) end if args['breakable'] then table.insert( symbols, symbol({ 'break', args['breakable'], size=default_size }) ) end if args['linkenblock'] then table.insert( symbols, symbol({ 'linken', args['linkenblock'], size=default_size }) ) end if args['bkbblock'] then table.insert( symbols, symbol({ 'bkb', args['bkbblock'], size=default_size }) ) end return table.concat( symbols, ' ' ) .. ' ' end

function p.target(frame) local args = getArgs(frame, {   wrappers = {      'Template:Ability'    }  }) local target_dict = { ["No Target"] = 'No Target', ["Target Unit"] = 'Target Unit', ["Target Point"] = 'Target Point', ["Target Area"] = 'Target Area', ["Passive"] = 'Passive', ["Aura"] = 'Aura', ["Toggle"] = 'Toggle', } local target2_dict = { ["No Target"] = ' / No Target', ["No Target aghs"] = ' (' .. symbol_aghs .. ' No Target )', ["No Target shard"] = ' (' .. symbol_shard .. ' No Target )', ["No Target tal"] = ' (' .. symbol_tal .. ' No Target )', ["Target Unit"] = ' / Target Unit', ["Target Unit aghs"] = ' (' .. symbol_aghs .. ' Target Unit )', ["Target Unit shard"] = ' (' .. symbol_shard .. ' Target Unit )', ["Target Unit tal"] = ' (' .. symbol_tal .. ' Target Unit )', ["Target Point"] = ' / Target Point', ["Target Point aghs"] = ' (' .. symbol_aghs .. ' Target Point )', ["Target Point shard"] = ' (' .. symbol_shard .. ' Target Point )', ["Target Point tal"] = ' (' .. symbol_tal .. ' Target Point )', ["Target Area"] = ' / Target Area', ["Target Area aghs"] = ' (' .. symbol_aghs .. ' Target Area )', ["Target Area shard"] = ' (' .. symbol_shard .. ' Target Area )', ["Target Area tal"] = ' (' .. symbol_tal .. ' Target Area )', ["Passive"] = ' / Passive', ["Passive aghs"] = ' (' .. symbol_aghs .. ' Passive )', ["Passive shard"] = ' (' .. symbol_shard .. ' Passive )', ["Passive tal"] = ' (' .. symbol_tal .. ' Passive )', ["Aura"] = ' / Aura', ["Aura aghs"] = ' (' .. symbol_aghs .. ' Aura )', ["Aura shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Aura )', ["Aura tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Aura )', ["Channeled"] = ' / Channeled', -- Should always be 2nd. ["Channeled aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Channeled )', ["Channeled shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Channeled )', ["Channeled tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Channeled )', ["Autocast"] = ' / Autocast', --Should always be 2nd. ["Autocast aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Autocast )', ["Autocast shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Autocast )', ["Autocast tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Autocast )', ["Toggle"] = ' / Toggle', ["Toggle aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Toggle )', ["Toggle shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Toggle )', ["Toggle tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Toggle )', ["Target Unit / Channeled"] = ' / Target Unit / Channeled', --Specifically for travel boots/tp scrolls. ["Target Unit aghs / Channeled"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Target Unit ) / Channeled', --Specifically for Tricks of the Trade. ["Target Unit or Area aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Target Unit / <span style="color:' .. color_aghs .. '; font-weight:bold">Target Area )', --Specifically for Eclipse. ["Target Self or Area shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Target Self / <span style="color:' .. color_shard .. '; font-weight:bold">Target Area )', --Specifically for Underlord Shard. ["Target Unit or Area shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Target Unit / <span style="color:' .. color_shard .. '; font-weight:bold">Target Area )', --Specifically for Underlord Shard. ["Target Unit / Target Area tal"] = ' / Target Unit (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Target Area )', --Specifically for Living Armor. ["Channeled / Autocast shard"] = ' / Channeled (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Autocast )', --Specifically for Elder Titan Shard. ["Vector"] = ' / Vector Targeting', } local target = target_dict[args['target']] or 'N/A' if args['target'] and args['target2'] then local target2 = target2_dict[args['target2']] or 'N/A' target = target .. ' ' .. target2 end return target end

function p.affects(frame) local args = getArgs(frame, {   wrappers = {      'Template:Ability'    }  }) -- Implements the Arc Warden easteregg. zet_easteregg = function if mw.title.getCurrentTitle.text == 'Arc Warden' then return 'The Self' else return 'Self' end end local affects_dict = { ["Heroes"] = 'Heroes', ["Enemy Heroes"] = 'Enemy Heroes', ["Allied Heroes"] = 'Allied Heroes', ["Units"] = 'Units', ["Enemy Units"] = 'Enemy Units', ["Allied Units"] = 'Allied Units', ["Self"] = zet_easteregg, ["Enemies"] = 'Enemies', ["Allies"] = 'Allies', ["Trees"] = 'Trees', ["Pumpkin Basket"] = 'Pumpkin Basket', } local affects2_dict = { ["Heroes"] = ' / Heroes', ["Heroes aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Heroes )', ["Heroes shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Heroes )', ["Heroes tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Heroes )', ["Enemy Heroes"] = ' / Enemy Heroes', ["Enemy Heroes aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Enemy Heroes )', ["Enemy Heroes shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Enemy Heroes )', ["Enemy Heroes tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Enemy Heroes )', ["Allied Heroes"] = ' / Allied Heroes', ["Allied Heroes aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Allied Heroes )', ["Allied Heroes shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Allied Heroes )', ["Allied Heroes tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Allied Heroes )', ["Units"] = ' / Units', ["Units aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Units )', ["Units shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Units )', ["Units tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Units )', ["Enemy Units"] = ' / Enemy Units', ["Enemy Units aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Enemy Units )', ["Enemy Units shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Enemy Units )', ["Enemy Units tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Enemy Units )', ["Allied Units"] = ' / Allied Units', ["Allied Units aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Allied Units )', ["Allied Units shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Allied Units )', ["Allied Units tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Allied Units )', ["Self"] = ' / Self', ["Self aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Self )', ["Self shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Self )', ["Self tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Self )', ["Enemies"] = ' / Enemies', ["Enemies aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Enemies )', ["Enemies shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Enemies )', ["Enemies tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Enemies )', ["Allies"] = ' / Allies', ["Allies aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Allies )', ["Allies shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Allies )', ["Allies tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Allies )', ["Trees"] = ' / Trees', ["Trees aghs"] = ' (' .. symbol_aghs .. ' <span style="color:' .. color_aghs .. '; font-weight:bold">Trees )', ["Trees shard"] = ' (' .. symbol_shard .. ' <span style="color:' .. color_shard .. '; font-weight:bold">Trees )', ["Trees tal"] = ' (' .. symbol_tal .. ' <span style="color:' .. color_tal.. '; font-weight:bold">Trees )', } if args['affects'] then local affects = affects_dict[args['affects']] if args['affects2'] then affects = affects .. ' ' .. affects2_dict[args['affects2']] end return "Affects " .. affects end end

-- Implements the damagetypes. function p.damagetype(frame) local args = getArgs(frame, {   wrappers = {      'Template:Ability'    }  }) local damagetype_dict = { ["Physical"] = ' Physical ', ["Magical"] = ' Magical ', ["Pure"] = ' Pure ', ["Instant Attack"] = ' Instant Attack ', ["Instant Attack tal"] = '' .. symbol_tal .. ' Instant Attack ', ["Instant Kill"] = ' Instant Kill ', ["Composite"] = ' Composite ', -- Use only for old abilities. ["Universal"] = ' Universal ', -- Use only for old abilities. ["HP Removal"] = 'HP Removal', -- Use only for old abilities. } local damagetype2_dict = { ["Physical"] = ' / Physical ', ["Physical aghs"] = ' (' .. symbol_aghs .. ' Physical )', ["Physical shard"] = ' (' .. symbol_shard .. ' Physical )', ["Physical tal"] = ' (' .. symbol_tal .. ' Physical )', ["Magical"] = ' / Magical ', ["Magical aghs"] = ' (' .. symbol_aghs .. ' Magical )', ["Magical shard"] = ' (' .. symbol_shard .. ' Magical )', ["Magical tal"] = ' (' .. symbol_tal .. ' Magical )', ["Pure"] = ' / Pure ', ["Pure aghs"] = ' (' .. symbol_aghs .. ' Pure )', ["Pure shard"] = ' (' .. symbol_shard .. ' Pure )', ["Pure tal"] = ' (' .. symbol_tal .. ' Pure )', ["Instant Attack"] = ' / Instant Attack ', ["Instant Attack aghs"] = ' (' .. symbol_aghs .. ' Instant Attack )', ["Instant Attack shard"] = ' (' .. symbol_shard .. ' Instant Attack )', ["Instant Attack tal"] = ' (' .. symbol_tal .. ' Instant Attack )', ["Instant Kill"] = ' / Instant Kill ', ["Instant Kill aghs"] = ' (' .. symbol_aghs .. ' Instant Kill )', ["Instant Kill shard"] = ' (' .. symbol_shard .. ' Instant Kill )', ["Instant Kill tal"] = ' (' .. symbol_tal .. ' Instant Kill )', ["HP Removal"] = ' (HP Removal)', -- Not an actual damage type, so should always be used as 2nd. } if args['damagetype'] then local damagetype = damagetype_dict[args['damagetype']] if args['damagetype2'] then damagetype = damagetype .. ' ' .. damagetype2_dict[args['damagetype2']] end return "Damage " .. damagetype end end

return p