Module:Effect

local p = {}

local g = require("Module:Common")

p.effect2name = { ['potion.moveSpeed'] = 'Speed'; ['potion.moveSlowdown'] = 'Slowness'; ['potion.digSpeed'] = 'Haste'; ['potion.digSlowDown'] = 'Mining Fatigue'; ['potion.damageBoost'] = 'Strength'; ['potion.heal'] = 'Instant Health'; ['potion.harm'] = 'Instant Damage'; ['potion.jump'] = 'Jump Boost'; ['potion.confusion'] = 'Nausea'; ['potion.regeneration'] = 'Regeneration'; ['potion.resistance'] = 'Resistance'; ['potion.fireResistance'] = 'Fire Resistance'; ['potion.waterBreathing'] = 'Water Breathing'; ['potion.invisibility'] = 'Invisibility'; ['potion.blindness'] = 'Blindness'; ['potion.nightVision'] = 'Night Vision'; ['potion.hunger'] = 'Hunger'; ['potion.weakness'] = 'Weakness'; ['potion.poison'] = 'Poison'; ['potion.wither'] = 'Wither'; ['potion.healthBoost'] = 'Health Boost'; ['potion.absorption'] = 'Absorption'; ['potion.saturation'] = 'Saturation'; }

p.effectNoImg = { ['potion.heal'] = true; ['potion.harm'] = true; ['potion.saturation'] = true; }

p.effectLvl = { 'I', 'II', 'III', 'IV', 'V' }

-- Returns the display name for a given effect name. function p.getEffectName(effect) return p.effect2name[g.trim(effect)] or '' end

-- Creates an effect link (with image) function p.makeEffect(effect, level, seconds) effect = g.trim(effect) local name = p.effect2name[effect] if (name == nil) then return '' else local out = '' if (p.effectNoImg[effect] == nil) then out = out .. g.img('Effect ' .. name .. '.png', nil, 'Status Effect#' .. name, name) end if (g.isGiven(level) and tonumber(level) and tonumber(level) > 1) then out = out .. ' ' .. g.link('Status Effect#' .. name, name .. ' ' .. p.effectLvl[tonumber(level)]) else out = out .. ' ' .. g.link('Status Effect#' .. name, name) end if (g.isGiven(seconds) and tonumber(seconds)) then out = out .. ' (' .. g.parseTime(tonumber(seconds)) .. ')' end return out end end

-- MediaWiki wrappers around the above functions function p.mwMakeEffect(frame) return p.makeEffect(frame.args[1], frame.args[2] or 0, frame.args[3]) end

return p