Module:DamageType

-- local loadLib = require('Module:LoadLib') loadLib(_G, {	onmain={ 'Module:Mainonly', field='on_main' }, }) local p = {}

-- Converts Aliases into ID's local aliases = require('Module:DamageType/Aliases') local damage_types = require('Module:DamageType/Data')

function p.getDamageType(frame) local args = getArgs(frame) local damage_type = args[1] local valBefore = args[2] local isShort = yesno(args["short"]) return p._getDamageType(damage_type, valBefore, isShort) end

function p.getDamageTypeShort(frame) local args = getArgs(frame) local damage_type = args[1] local valBefore = args[2] return p._getDamageType(damage_type, valBefore, true) end

function p._getDamageType(damage_type, valBefore, isShort) checkType(1, damage_type, 'string') checkType(2, valBefore, { 'string', 'number'}, true) checkType(3, isShort, 'boolean', true) local oldDamage_type = damage_type local damage_type, tier = damage_type:match('^(.+) ([%divxIVX]+)$') damage_type = (damage_type or oldDamage_type):lower tier = string._toRoman(string._toArabic(tier)) damage_type = damage_type:lower:gsub('_', ' ') damage_type = aliases[damage_type] or damage_type local damage_type = damage_types[damage_type] if not damage_type then return string.error("Invalid damage type %q", damage_type) end return string.wrapHtml{ {			string.makeImage(				damage_type.icon,				{					size=damage_type.size or "24x24px",					link=damage_type.name,				}			), string.wrapHtml{' ', " ", {style='font-family:initial;';}}, string.makeLink(damage_type.link and damage_type.link or damage_type.name, string.wrapHtml{				{					damage_type[isShort and 'nameShort' or 'name'], tier ~= 0 and " "..tier or ''				}, ' ', {					style={						color=damage_type.color					}				}			}), valBefore and ' ' or '', valBefore and string.wrapHtml(valBefore, 'font', {style={color=damage_type.color}}) or "", },		' ', {			style="whitespace: no-wrap;"; }	} end

return p