Difference between revisions of "Module:Infobox Boss"
From ALttP Speedrunning Wiki
(7 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
local sprdmg = require('Module:Sprite Damage') | local sprdmg = require('Module:Sprite Damage') | ||
+ | local hearts = require('Module:Damage display')._main | ||
local weapon_names = { | local weapon_names = { | ||
Line 23: | Line 24: | ||
local spr_id = tonumber(args.id:gsub('0x', ''), 16) | local spr_id = tonumber(args.id:gsub('0x', ''), 16) | ||
− | local hp = tonumber(args.hp, 10) | + | local hp = sprdmg._getHPForId(spr_id) or tonumber(args.hp or 0, 10) |
local spr_dmg = { | local spr_dmg = { | ||
Line 57: | Line 58: | ||
if (args.hammer or ''):lower() == 'no' then | if (args.hammer or ''):lower() == 'no' then | ||
− | spr_dmg[' | + | spr_dmg['hammer'] = 0 |
else | else | ||
spr_dmg['hammer'] = spr_dmg['sword 3'] | spr_dmg['hammer'] = spr_dmg['sword 3'] | ||
end | end | ||
+ | |||
+ | local bump = { | ||
+ | green = hearts(sprdmg._getBumpForId(spr_id, 'green')), | ||
+ | blue = hearts(sprdmg._getBumpForId(spr_id, 'blue')), | ||
+ | red = hearts(sprdmg._getBumpForId(spr_id, 'red')) | ||
+ | } | ||
local ret = mw.html.create('table') | local ret = mw.html.create('table') | ||
Line 79: | Line 86: | ||
:wikitext('Location') | :wikitext('Location') | ||
:done() | :done() | ||
− | :tag(' | + | :tag('td') |
:attr('colspan', '4') | :attr('colspan', '4') | ||
− | :wikitext(location) | + | :wikitext(args.location) |
:done() | :done() | ||
:done() | :done() | ||
Line 90: | Line 97: | ||
:tag('td') | :tag('td') | ||
:css('font-weight', 'bold') | :css('font-weight', 'bold') | ||
+ | :css('text-align', 'right') | ||
:wikitext(hp) | :wikitext(hp) | ||
:done() | :done() | ||
Line 96: | Line 104: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['arrow'], hp)) | :wikitext(fmtdmg(spr_dmg['arrow'], hp)) | ||
:done() | :done() | ||
Line 102: | Line 111: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['silver'], hp)) | :wikitext(fmtdmg(spr_dmg['silver'], hp)) | ||
:done() | :done() | ||
Line 111: | Line 121: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['sword 1'], hp)) | :wikitext(fmtdmg(spr_dmg['sword 1'], hp)) | ||
:done() | :done() | ||
Line 117: | Line 128: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['somaria'], hp)) | :wikitext(fmtdmg(spr_dmg['somaria'], hp)) | ||
:done() | :done() | ||
Line 123: | Line 135: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['byrna'], hp)) | :wikitext(fmtdmg(spr_dmg['byrna'], hp)) | ||
:done() | :done() | ||
Line 132: | Line 145: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['sword 2'], hp)) | :wikitext(fmtdmg(spr_dmg['sword 2'], hp)) | ||
:done() | :done() | ||
Line 138: | Line 152: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['fire rod'], hp)) | :wikitext(fmtdmg(spr_dmg['fire rod'], hp)) | ||
:done() | :done() | ||
Line 144: | Line 159: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['ice rod'], hp)) | :wikitext(fmtdmg(spr_dmg['ice rod'], hp)) | ||
:done() | :done() | ||
Line 153: | Line 169: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['sword 3'], hp)) | :wikitext(fmtdmg(spr_dmg['sword 3'], hp)) | ||
:done() | :done() | ||
Line 159: | Line 176: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['hammer'], hp)) | :wikitext(fmtdmg(spr_dmg['hammer'], hp)) | ||
:done() | :done() | ||
Line 165: | Line 183: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['bomb'], hp)) | :wikitext(fmtdmg(spr_dmg['bomb'], hp)) | ||
:done() | :done() | ||
Line 174: | Line 193: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['sword 4'], hp)) | :wikitext(fmtdmg(spr_dmg['sword 4'], hp)) | ||
:done() | :done() | ||
Line 180: | Line 200: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['boomerang'], hp)) | :wikitext(fmtdmg(spr_dmg['boomerang'], hp)) | ||
:done() | :done() | ||
Line 186: | Line 207: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['hookshot'], hp)) | :wikitext(fmtdmg(spr_dmg['hookshot'], hp)) | ||
:done() | :done() | ||
Line 195: | Line 217: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['bombos'], hp)) | :wikitext(fmtdmg(spr_dmg['bombos'], hp)) | ||
:done() | :done() | ||
Line 201: | Line 224: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['ether'], hp)) | :wikitext(fmtdmg(spr_dmg['ether'], hp)) | ||
:done() | :done() | ||
Line 207: | Line 231: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
+ | :addClass('damage') | ||
:wikitext(fmtdmg(spr_dmg['quake'], hp)) | :wikitext(fmtdmg(spr_dmg['quake'], hp)) | ||
:done() | :done() | ||
Line 216: | Line 241: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
− | :css(' | + | :css('vertical-align', 'top') |
− | :wikitext( | + | :wikitext(bump.green) |
:done() | :done() | ||
:tag('td') | :tag('td') | ||
Line 223: | Line 248: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
− | :css(' | + | :css('vertical-align', 'top') |
− | :wikitext( | + | :wikitext(bump.blue) |
:done() | :done() | ||
:tag('td') | :tag('td') | ||
Line 230: | Line 255: | ||
:done() | :done() | ||
:tag('td') | :tag('td') | ||
− | :css(' | + | :css('vertical-align', 'top') |
− | :wikitext( | + | :wikitext(bump.red) |
:done() | :done() | ||
:done() | :done() | ||
Line 255: | Line 280: | ||
function fmtdmg(damage, hp) | function fmtdmg(damage, hp) | ||
if unique_damage[damage] then | if unique_damage[damage] then | ||
− | return | + | return unique_damage[damage] |
elseif damage >= hp then | elseif damage >= hp then | ||
− | return string.format('<span class=" | + | return string.format('<span class="spr-ohko">%d</span>', damage) |
else | else | ||
if damage == 0 then | if damage == 0 then | ||
damage = '-' | damage = '-' | ||
end | end | ||
− | return | + | return damage |
end | end | ||
end | end | ||
return p | return p |
Latest revision as of 15:09, 7 June 2019
Documentation for this module may be created at Boss/doc&action=edit&redlink=1 Module:Infobox Boss/doc
-- <nowiki> local p = {} local sprdmg = require('Module:Sprite Damage') local hearts = require('Module:Damage display')._main local weapon_names = { 'boomerang', 'sword 1', 'sword 2', 'sword 3', 'sword 4', 'sword 5', 'arrow', 'hookshot', 'bomb', 'silver', 'powder', 'fire rod', 'ice rod', 'bombos', 'ether', 'quake' } local unique_damage = { [0xF9] = 'Fairy', [0xFA] = 'Slime', [0xFB] = 'Short stun', [0xFC] = 'Stun', [0xFD] = 'Burn', [0xFE] = 'Freeze', [0xFF] = 'Long stun' } function p.main(frame) local args = frame:getParent().args local spr_id = tonumber(args.id:gsub('0x', ''), 16) local hp = sprdmg._getHPForId(spr_id) or tonumber(args.hp or 0, 10) local spr_dmg = { ['boomerang'] = sprdmg._getDamageForId(spr_id, 'boomerang'), ['sword 1'] = sprdmg._getDamageForId(spr_id, 'sword 1'), ['sword 2'] = sprdmg._getDamageForId(spr_id, 'sword 2'), ['sword 3'] = sprdmg._getDamageForId(spr_id, 'sword 3'), ['sword 4'] = sprdmg._getDamageForId(spr_id, 'sword 4'), ['sword 5'] = sprdmg._getDamageForId(spr_id, 'sword 5'), ['arrow'] = sprdmg._getDamageForId(spr_id, 'arrow'), ['hookshot'] = sprdmg._getDamageForId(spr_id, 'hookshot'), ['bomb'] = sprdmg._getDamageForId(spr_id, 'bomb'), ['silver'] = sprdmg._getDamageForId(spr_id, 'silver'), ['powder'] = sprdmg._getDamageForId(spr_id, 'powder'), ['fire rod'] = sprdmg._getDamageForId(spr_id, 'fire rod'), ['ice rod'] = sprdmg._getDamageForId(spr_id, 'ice rod'), ['bombos'] = sprdmg._getDamageForId(spr_id, 'bombos'), ['ether'] = sprdmg._getDamageForId(spr_id, 'ether'), ['quake'] = sprdmg._getDamageForId(spr_id, 'quake') } if (args.byrna or ''):lower() == 'no' then spr_dmg['byrna'] = 0 else spr_dmg['byrna'] = spr_dmg['sword 1'] end if (args.somaria or ''):lower() == 'no' then spr_dmg['somaria'] = 0 else spr_dmg['somaria'] = spr_dmg['sword 1'] end if (args.hammer or ''):lower() == 'no' then spr_dmg['hammer'] = 0 else spr_dmg['hammer'] = spr_dmg['sword 3'] end local bump = { green = hearts(sprdmg._getBumpForId(spr_id, 'green')), blue = hearts(sprdmg._getBumpForId(spr_id, 'blue')), red = hearts(sprdmg._getBumpForId(spr_id, 'red')) } local ret = mw.html.create('table') :addClass('wikitable infobox') ret :tag('caption') :wikitext(args.name) :done() :tag('tr') :tag('td') :attr('colspan', '6') :wikitext(string.format('[[File:%s|240px|center]]', args.image)) :done() :done() :tag('tr') :tag('th') :attr('colspan', '2') :wikitext('Location') :done() :tag('td') :attr('colspan', '4') :wikitext(args.location) :done() :done() :tag('tr') :tag('th') :wikitext('HP') :done() :tag('td') :css('font-weight', 'bold') :css('text-align', 'right') :wikitext(hp) :done() :tag('td') :wikitext('[[File:Icon Bow.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['arrow'], hp)) :done() :tag('td') :wikitext('[[File:Icon Silver Bow.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['silver'], hp)) :done() :done() :tag('tr') :tag('td') :wikitext('[[File:Icon L1 Sword.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['sword 1'], hp)) :done() :tag('td') :wikitext('[[File:Icon Cane of Somaria.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['somaria'], hp)) :done() :tag('td') :wikitext('[[File:Icon Cane of Byrna.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['byrna'], hp)) :done() :done() :tag('tr') :tag('td') :wikitext('[[File:Icon L2 Sword.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['sword 2'], hp)) :done() :tag('td') :wikitext('[[File:Icon Fire Rod.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['fire rod'], hp)) :done() :tag('td') :wikitext('[[File:Icon Ice Rod.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['ice rod'], hp)) :done() :done() :tag('tr') :tag('td') :wikitext('[[File:Icon L3 Sword.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['sword 3'], hp)) :done() :tag('td') :wikitext('[[File:Icon Hammer.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['hammer'], hp)) :done() :tag('td') :wikitext('[[File:Icon Bombs.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['bomb'], hp)) :done() :done() :tag('tr') :tag('td') :wikitext('[[File:Icon L4 Sword.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['sword 4'], hp)) :done() :tag('td') :wikitext('[[File:Icon Boomerang.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['boomerang'], hp)) :done() :tag('td') :wikitext('[[File:Icon Hookshot.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['hookshot'], hp)) :done() :done() :tag('tr') :tag('td') :wikitext('[[File:Icon Bombos.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['bombos'], hp)) :done() :tag('td') :wikitext('[[File:Icon Ether.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['ether'], hp)) :done() :tag('td') :wikitext('[[File:Icon Quake.png|link=]]') :done() :tag('td') :addClass('damage') :wikitext(fmtdmg(spr_dmg['quake'], hp)) :done() :done() :tag('tr') :tag('td') :wikitext('[[File:Icon Green Mail.png|link=]]') :done() :tag('td') :css('vertical-align', 'top') :wikitext(bump.green) :done() :tag('td') :wikitext('[[File:Icon Blue Mail.png|link=]]') :done() :tag('td') :css('vertical-align', 'top') :wikitext(bump.blue) :done() :tag('td') :wikitext('[[File:Icon Red Mail.png|link=]]') :done() :tag('td') :css('vertical-align', 'top') :wikitext(bump.red) :done() :done() :tag('tr') :tag('td') :addClass('prevBoss') :attr('colspan', '3') :wikitext(args['prev_boss']) :done() :tag('td') :addClass('nextBoss') :attr('colspan', '3') :wikitext(args['next_boss']) :done() :done() :done() :done() return ret end function fmtdmg(damage, hp) if unique_damage[damage] then return unique_damage[damage] elseif damage >= hp then return string.format('<span class="spr-ohko">%d</span>', damage) else if damage == 0 then damage = '-' end return damage end end return p