Module:Ability details/sandbox

local getArgs = require( 'Module:Arguments' ).getArgs local mFileLink = require('Module:File link')._main local tooltip = require('Module:Tooltip')._main local health = require('Module:Health')._main

local p = {}

function p.symbols(frame) local args = getArgs(frame) return p._symbols(args) end

-- =p._symbols({type="ultimate", ["ultimate type"]="Cast-Time"}) function p._symbols(args) local default_size = '20px' local symbols = {}

if args['type'] == 'Ultimate' then if args['ultimate type'] == "Cast-Time" then table.insert(symbols, tooltip({mFileLink({file="icon-clock-white.png", size=default_size,link=''}),"Casting canceled by stuns"})) end if args['ultimate type'] == "Channeled" then table.insert(symbols, tooltip({mFileLink({file="Achievement Lockdown.png", size=default_size,link=''}),"Can be interrupted by any stun. Abilities disabled."})) end if args['ultimate type'] == "Transformation" then table.insert(symbols, tooltip({mFileLink({file="Icon-ability.0SgzU.png", size=default_size,link=''}),"Cannot be interrupted. Target can still use weapons and abilities"})) end if args['ultimate type'] == "Built" then table.insert(symbols, tooltip({mFileLink({file="Icon-ability.0cgjd.png", size=default_size,link=''}),"Cannot be interrupted. Prompts user for location"})) end end if args['type'] == 'Passive' then table.insert(symbols, tooltip({mFileLink({file="Ability-passive.png", size=default_size,link=''}),"Passive ability"})) end

return table.concat( symbols, ' ' ) .. ' ' end

function p.accuracy(frame) local args = getArgs(frame) return p._accuracy(args) end

-- =p._accuracy({accuracy="pinpoint", accuracy2="spread"}) -- =p._accuracy({spread="3"}) -- If spread is passed automatically set accuracy to spread function p._accuracy(args) local accuracy_dict = { ['pinpoint'] = 'Pinpoint', ['spread'] = 'Spread', ['targeted'] = 'Targeted', ['aoe'] = 'Area of Effect', }

local accuracy2_dict = { ['scoped'] = 'Scoped', } local accuracy = accuracy_dict[args['accuracy']] or 'N/A' if accuracy == 'N/A' then if args['spread'] then accuracy = accuracy_dict['spread'] end end if args['accuracy'] and args['accuracy2'] then local accuracy2 = accuracy2_dict[args['accuracy2']] or accuracy_dict[args['accuracy2']] or 'N/A' accuracy = accuracy .. ' ' .. accuracy2 end return accuracy end

function p.travel(frame) local args = getArgs(frame) return p._travel(args) end

-- =p._travel({travel='projectile'}) function p._travel(args) local travel_dict = { ['projectile'] = 'Projectile', ['arc'] = 'Arcing Projectile', ['hitscan'] = 'Hitscan', } local travel = travel_dict[args['travel']] or 'N/A'

return travel end

function p.affects(frame) local args = getArgs(frame) return p._affects(args) end

function p._affects(args) local affects_dict = { ['allies'] = 'Allies', ['enemies'] = 'Enemies', ['self'] = 'Self', ['none'] = 'N/A', }

local affects = affects_dict[args['affects']] or affects_dict['enemies'] if args['affects'] and args['affects2'] then local affects2 = affects_dict[args['affects2']] or 'N/A' affects = affects .. ' ' .. affects2 end return affects end

--Add a data row function dataRow(name, value) return mw.getCurrentFrame:expandTemplate{ title = 'Ability details/sandbox/Data row', args = {name = name, value = value} } end

function p.traits(frame) local args = getArgs(frame) return p._traits(args) end

-- =p._traits({trait1="Test trait 1", value1 = "Test value 1", trait2="Test 2", value2="TVal 2"}) -- =p._traits({trait1="Extra Damage", value1 = "100", trait2="Damage Reduction", value2="50%"}) -- =p._traits({trait1="Extra Damage (to armor)", value1 = "100", trait2="Healing", value2="50"}) function p._traits(args) local traits = {} local traitNum = 1 while args['trait' .. traitNum] and args['value' .. traitNum] do   local curtrait = args['trait' .. traitNum] local curval = args['value' .. traitNum] if string.match(curtrait, "Damage") and not string.match(curval, '%%') then local type = 'health' if string.match(curtrait, "armor") then type = 'armor' end curval = healthVisual(curval, type) end table.insert( traits, dataRow(curtrait, curval) ) traitNum = traitNum + 1 end return table.concat( traits, '' ) end

function p.damage(frame) local args = getArgs(frame) return p._damage(args) end

-- creates a representation of health/damage, with text describing duration/type/etc function healthVisual(amount, type, pellets, shot, duration) local totalDamage = amount * (pellets or 1) local content if type == 'health' then content = health{health = totalDamage} elseif type == 'armor' then content = health{armor = totalDamage} elseif type == 'shields' then content = health{shields = totalDamage} elseif type == 'tarmor' then content = health{tarmor = totalDamage} elseif type == 'tshields' then content = health{tshields = totalDamage} end local tt = ' ' .. totalDamage -- Add per shot for weapons or ammo if shot then tt = tt .. ' per shot' end if pellets then tt = tt .. ' (' .. amount .. ' per pellet)' end if duration then tt = tt .. ' over ' .. duration .. ' s' end return content .. tt end

-- =p._damage({damage=100, pellets=5, ['damage duration']=5}) -- =p._damage({healing=10, ['healing duration']=5}) -- Test falloff -- =p._damage({damage=1, pellets=5, ['damage duration']=5, ['damage falloff start']=5, ['damage falloff end']=10}) function p._damage(args) local damages = {}

if args['damage'] then -- Add per shot for weapons or ammo local shot if args['ammo'] or args['type'] == 'Weapon' then shot = true end

local maxDamage = healthVisual(args['damage'], 'health', args['pellets'], shot, args['damage duration']) local minDamage

if args['damage falloff start'] and args['damage falloff end'] then minDamage = healthVisual(       mw.getCurrentFrame:expandTemplate{title = 'FalloffDamage', args = {['base damage'] = args['damage'], start = args['damage falloff start'], ['end'] = args['damage falloff end'], falloff = args['damage falloff min']} },        'health',         args['pellets'],         shot,         args['damage duration']      ) maxDamage = maxDamage .. ' – ' .. minDamage end table.insert( damages, dataRow('Damage', maxDamage) ) end if args['healing'] then table.insert( damages, dataRow('Healing', healthVisual(args['healing'], 'health', args['pellets'], '', args['healing duration']) ) ) end return table.concat( damages, '' )

end

return p