Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

Module:Ability

From Dota 2 Wiki
Jump to: navigation, search

Documentation for Module:Ability Jump to code ↴ [ edit | purge ]

Reality Rift icon.png
▶️ Planeshift.
The documentation for this module can be found at Template:Ability.
You may be forwarded to another wiki language, in case a translation is not available.


Dependencies

local symbol = require( 'Module:Symbol' )._main
local symbol_aghs = symbol({ 'Aghanim' })
local symbol_tal = symbol({ 'Talent' })
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', 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"] = '[[Abilities#No Target|No Target]]',
    ["Target Unit"] = '[[Abilities#Target Unit|Target Unit]]',
    ["Target Point"] = '[[Abilities#Target Point|Target Point]]',
    ["Target Area"] = '[[Abilities#Target Area|Target Area]]',
    ["Passive"] = '[[Abilities#Passive|Passive]]',
    ["Aura"] = '[[Aura]]',                     
    ["Toggle"] = '[[Abilities#Toggle|Toggle]]',
  }
  local target2_dict = {
    ["No Target"] = ' / [[Abilities#No Target|No Target]]',
    ["No Target aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#No Target|<span style="color:#538028;">No Target</span>]])',
    ["No Target tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#No Target|No Target]])',
    ["Target Unit"] = ' / [[Abilities#Target Unit|Target Unit]]',
    ["Target Unit aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Target Unit|<span style="color:#538028;">Target Unit</span>]])',
    ["Target Unit tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Target Unit|Target Unit]])',
    ["Target Point"] = ' / [[Abilities#Target Point|Target Point]]',
    ["Target Point aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Target Point|<span style="color:#538028;">Target Point</span>]])',
    ["Target Point tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Target Point|Target Point]])',
    ["Target Area"] = ' / [[Abilities#Target Area|Target Area]]',
    ["Target Area aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Target Area|<span style="color:#538028;">Target Area</span>]])',
    ["Target Area tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Target Area|Target Area]])',
    ["Passive"] = ' / [[Abilities#Passive|Passive]]',
    ["Passive aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Passive|<span style="color:#538028;">Passive</span>]])',
    ["Passive tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Passive|Passive]])',
    ["Aura"] = ' / [[Aura]]',
    ["Aura aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Aura|<span style="color:#538028;">Aura</span>]])',
    ["Aura tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Aura]])',
    ["Channeled"] = ' / [[Channeling|Channeled]]', -- Should always be 2nd.
    ["Channeled aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Channeling|<span style="color:#538028;">Channeled</span>]])',
    ["Channeled tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Channeling|Channeled]])',
    ["Autocast"] = ' / [[Abilities#Autocast|Autocast]]', --Should always be 2nd.
    ["Autocast aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Autocast|<span style="color:#538028;">Autocast</span>]])',
    ["Autocast tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Autocast|Autocast]])',
    ["Toggle"] = ' / [[Abilities#Toggle|Toggle]]',
    ["Toggle aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Toggle|<span style="color:#538028;">Toggle</span>]])',
    ["Toggle tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Toggle|Toggle]])',
    ["Target Unit / Channeled"] = ' / [[Abilities#Target Unit|Target Unit]] / [[Channeling|Channeled]]', --Specifically for travel boots/tp scrolls.
    ["Target Unit aghs / Channeled"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Target Unit|<span style="color:#538028;">Target Unit</span>]]) / [[Channeling|Channeled]] ', --Specifically for Tricks of the Trade.
    ["Target Unit or Area aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Abilities#Target Unit|<span style="color:#538028;">Target Unit</span>]] / [[Abilities#Target Area|<span style="color:#538028;">Target Area</span>]]) ', --Specifically for Eclipse.
    ["Target Unit / Target Area tal"] = ' / [[Abilities#Target Unit|Target Unit]]<br>(' .. symbol_tal .. '&nbsp;[[Abilities#Target Area|Target Area]]) ', --Specifically for Living Armor.
    ["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"] = '[[Heroes|Enemy Heroes]]',
    ["Allied Heroes"] = '[[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"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Heroes|<span style="color:#538028;">Heroes</span>]])',
    ["Heroes tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Heroes]])',
    ["Enemy Heroes"] = ' / [[Heroes|Enemy Heroes]]',
    ["Enemy Heroes aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Heroes|<span style="color:#538028;">Enemy Heroes</span>]])',
    ["Enemy Heroes tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Heroes|Enemy Heroes]])',
    ["Allied Heroes"] = ' / [[Heroes|Allied Heroes]]',
    ["Allied Heroes aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Heroes|<span style="color:#538028;">Allied Heroes</span>]])',
    ["Allied Heroes tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Heroes|Allied Heroes]])',
    ["Units"] = ' / Units',
    ["Units aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;<span style="color:#538028;">Units</span>)',
    ["Units tal"] = '<br>(' .. symbol_tal .. '&nbsp;Units)',
    ["Enemy Units"] = ' / Enemy Units',
    ["Enemy Units aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;<span style="color:#538028;">Enemy Units</span>)',
    ["Enemy Units tal"] = '<br>(' .. symbol_tal .. '&nbsp;Enemy Units)',
    ["Allied Units"] = ' / Allied Units',
    ["Allied Units aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;<span style="color:#538028;">Allied Units</span>)',
    ["Allied Units tal"] = '<br>(' .. symbol_tal .. '&nbsp;Allied Units)',
    ["Self"] = ' / Self',
    ["Self aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;<span style="color:#538028;">Self</span>)',
    ["Self tal"] = '<br>(' .. symbol_tal .. '&nbsp;Self)',
    ["Enemies"] = ' / Enemies',
    ["Enemies aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;<span style="color:#538028;">Enemies</span>)',
    ["Enemies tal"] = '<br>(' .. symbol_tal .. '&nbsp;Enemies)',
    ["Allies"] = ' / Allies',
    ["Allies aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;<span style="color:#538028;">Allies</span>)',
    ["Allies tal"] = '<br>(' .. symbol_tal .. '&nbsp;Allies)',
    ["Trees"] = ' / [[Trees]]',
    ["Trees aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Trees|<span style="color:#538028;">Trees]]</span>)',
    ["Trees tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Trees]])',
  }
  if args['affects'] then
    local affects = affects_dict[args['affects']]
    if args['affects2'] then
      affects = affects .. ' ' .. affects2_dict[args['affects2']]
    end
    return "'''Affects'''<br>" .. affects
  end
end

-- Implements the damagetypes.
function p.damagetype(frame)
  local args = getArgs(frame, {
    wrappers = {
      'Template:Ability'
    }
  })
  local damagetype_dict = {
    ["Physical"] = '[[Damage types#Physical|<span style="color:#AE2F28; font-weight:bold">Physical</span>]]',
    ["Magical"] = '[[Damage types#Magical|<span style="color:#5B93D1; font-weight:bold">Magical</span>]]',
    ["Pure"] = '[[Damage types#Pure|<span style="color:#D8AE53; font-weight:bold">Pure</span>]]',
    ["Composite"] = '[[Damage types#Composite|<span style="color:#5BD199; font-weight:bold">Composite</span>]]', -- Use only for old abilities.
    ["Universal"] = '[[Damage types#Universal|<span style="color:#8650AC; font-weight:bold">Universal</span>]]', -- Use only for old abilities.
    ["HP Removal"] = '[[Damage types#HP Removal|HP Removal]]', -- Use only for old abilities.
  }
  local damagetype2_dict = {
    ["Physical"] = ' / [[Damage types#Physical|<span style="color:#AE2F28; font-weight:bold">Physical</span>]]',
    ["Physical aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Damage types#Physical|<span style="color:#AE2F28; font-weight:bold">Physical</span>]])',
    ["Physical tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Damage types#Physical|<span style="color:#AE2F28; font-weight:bold">Physical</span>]])',
    ["Magical"] = ' / [[Damage types#Magical|<span style="color:#5B93D1; font-weight:bold">Magical</span>]]',
    ["Magical aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Damage types#Magical|<span style="color:#5B93D1; font-weight:bold">Magical</span>]])',
    ["Magical tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Damage types#Magical|<span style="color:#5B93D1; font-weight:bold">Magical</span>]])',
    ["Pure"] = ' / [[Damage types#Pure|<span style="color:#D8AE53; font-weight:bold">Pure</span>]]',
    ["Pure aghs"] = '<br>(' .. symbol_aghs .. '&nbsp;[[Damage types#Pure|<span style="color:#D8AE53; font-weight:bold">Pure</span>]])',
    ["Pure tal"] = '<br>(' .. symbol_tal .. '&nbsp;[[Damage types#Pure|<span style="color:#D8AE53; font-weight:bold">Pure</span>]])',
    ["HP Removal"] = '<br>([[Damage types#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'''<br>" .. damagetype
  end
end


return p