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 txtshdw = "; text-shadow: 1px 1px 1px black" local damage_types = { ['melee']={ name="Melee Damage", nameShort="Melee Dmg", icon="Iron_Sword.png", color="#eee"..txtshdw },	['projectile']={ name="Projectile Damage", nameShort="Proj. Dmg", icon="Arrow.png", color="#AAAAAA" },	['fall']={ name="Fall Damage", nameShort="Fall Dmg", icon="Feather.png", color="#555555" },	['drown']={ name="Drown Damage", nameShort="Drown Dmg", icon="Water_Block.png", color="#55FFFF" },	['fire']={ name="Fire Damage", nameShort="Fire Dmg", icon="Fire.png", color="#FF5555" },	['lava']={ name="Lava Damage", nameShort="Lava Dmg", icon="Lava_Block.png", color="#AA0000" },	['magic']={ name="Magic Damage", nameShort="Magic Dmg", icon="Spirit Sceptre.png", color="#00AAAA" } }

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.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