Module:AbilityHints: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Gammaton32 (talk | contribs) Changed melee icon to melee charge since I think it's more intuitive/readable Tags: Mobile edit Mobile web edit Advanced mobile edit |
m support manual ability hints |
||
| Line 1: | Line 1: | ||
-- | -- Small item icons on ability cards showing how an ability interacts with items (dispellable, reduced, blocked, etc.). | ||
-- Used by Template:AbilitySection. Styles are there too. | |||
-- | |||
local AbilityTable = require("Module:AbilityTable") | local AbilityTable = require("Module:AbilityTable") | ||
| Line 10: | Line 8: | ||
-- Display order. Each entry: { list, file, link, tip } | -- Display order. Each entry: { list, file, link, tip } | ||
local CONFIG = { | local CONFIG = { | ||
{ list = "melee", file = "Melee Charge.png", link = "https://deadlock.wiki/Melee_Charge", tip = "Benefits from melee items" }, | { list = "melee", file = "Melee Charge.png", link = "https://deadlock.wiki/Melee_Charge", tip = "Benefits from melee items" }, | ||
{ list = "movementbased", file = "Slowing Hex.png", link = "https://deadlock.wiki/Slowing_Hex", tip = "Disabled by Slowing Hex" }, | { list = "movementbased", file = "Slowing Hex.png", link = "https://deadlock.wiki/Slowing_Hex", tip = "Disabled by Slowing Hex" }, | ||
{ list = "debuffresist", file = "Debuff Reducer.png", link = "https://deadlock.wiki/Debuff_Reducer", tip = "Debuff duration reduced by Debuff Resist" }, | |||
{ list = "heal", file = "Healing Booster.png", link = "https://deadlock.wiki/Healing_Booster", tip = "Healing amplified by Healing Booster and affected by healing reduction" }, | { list = "heal", file = "Healing Booster.png", link = "https://deadlock.wiki/Healing_Booster", tip = "Healing amplified by Healing Booster and affected by healing reduction" }, | ||
{ list = "reactivebarrier", file = "Reactive Barrier.png", link = "https://deadlock.wiki/Reactive_Barrier", tip = "Triggers Reactive Barrier" }, | { list = "reactivebarrier", file = "Reactive Barrier.png", link = "https://deadlock.wiki/Reactive_Barrier", tip = "Triggers Reactive Barrier" }, | ||
| Line 28: | Line 21: | ||
} | } | ||
local function icon_img(file, link) | local function icon_img(file, link) | ||
return '<span style="position:relative;bottom:2px;">[[File:' .. file .. '|24px|link=' .. link .. ']]</span>' | return '<span style="position:relative;bottom:2px;">[[File:' .. file .. '|24px|link=' .. link .. ']]</span>' | ||
end | end | ||
local function hint_icon(def) | local function hint_icon(def) | ||
return '<span class="ability-hint">' .. icon_img(def.file, def.link) | return '<span class="ability-hint">' .. icon_img(def.file, def.link) | ||
| Line 41: | Line 30: | ||
end | end | ||
-- | local function manual_icon(m) | ||
-- | local cls = 'ability-hint' | ||
if m.disabled then cls = cls .. ' ability-hint--disabled' end | |||
-- | return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor) | ||
function p.get_icons(ability_key, ability_num) | .. '<span class="ability-hint-tip">' .. m.title .. ' Interaction. Click to see more</span></span>' | ||
end | |||
local | function p.get_icons(ability_key, ability_num, manual) | ||
manual = manual or {} | |||
-- Files claimed by a manual icon suppress the matching automatic icon. | |||
local manual_files = {} | |||
for _, m in ipairs(manual) do | |||
manual_files[mw.ustring.lower(m.file)] = true | |||
end | |||
local icons = {} | local icons = {} | ||
for _, def in ipairs(CONFIG) do | |||
local record = ability_data[ability_key] | |||
if record ~= nil then | |||
local num = tonumber(ability_num) | |||
for _, def in ipairs(CONFIG) do | |||
if AbilityTable.is_member(def.list, record, num) | |||
and not manual_files[mw.ustring.lower(def.file)] then | |||
table.insert(icons, hint_icon(def)) | |||
end | |||
end | end | ||
end | |||
for _, m in ipairs(manual) do | |||
table.insert(icons, manual_icon(m)) | |||
end | end | ||