Editing Module:AbilityHintsGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 1: | Line 1: | ||
-- Small item icons on ability cards showing how an ability interacts with items (dispellable, reduced, blocked, etc.). | -- 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. | -- Used by Template:AbilitySection. Styles are there too. | ||
local AbilityTable = require("Module:AbilityTable") | local AbilityTable = require("Module:AbilityTable") | ||
local | local ability_data = mw.loadJsonData("Data:AbilityData.json") | ||
local p = {} | local p = {} | ||
-- Display order: | -- Display order. Each entry: { list, file, link, tip } | ||
local | local CONFIG = { | ||
{ 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 = "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 = "reactivebarrier", file = "Reactive Barrier.png", link = "https://deadlock.wiki/Reactive_Barrier", tip = "Triggers Reactive Barrier" }, | |||
{ list = "dispelmagic", file = "Dispel Magic.png", link = "https://deadlock.wiki/Dispel_Magic", tip = "Effect can be dispelled" }, | |||
{ list = "indomitable", file = "Indomitable.png", link = "https://deadlock.wiki/Indomitable", tip = "Disable prevented by Indomitable" }, | |||
{ list = "unstoppable", file = "Unstoppable.png", link = "https://deadlock.wiki/Unstoppable", tip = "Disable prevented by Unstoppable" }, | |||
{ list = "platedarmor", file = "Plated Armor.png", link = "https://deadlock.wiki/Plated_Armor", tip = "On-shot effect prevented by Plated Armor" }, | |||
{ list = "summons", file = "Monster Rounds.png", link = "https://deadlock.wiki/Monster_Rounds", tip = "Summons affected by Monster Rounds and Heroic Aura" }, | |||
} | |||
} | |||
local function icon_img(file, link) | |||
return '<span style="position:relative;bottom:2px;">[[File:' .. file .. '|24px|link=' .. link .. ']]</span>' | |||
local function icon_img(file, link | |||
end | end | ||
local function hint_icon(def) | local function hint_icon(def) | ||
return '<span class="ability-hint">' .. icon_img(def.file) | return '<span class="ability-hint">' .. icon_img(def.file, def.link) | ||
.. '<span class="ability-hint-tip">' .. | .. '<span class="ability-hint-tip">' .. def.tip .. '</span></span>' | ||
end | end | ||
local function manual_icon(m) | local function manual_icon(m) | ||
local cls = 'ability-hint' | local cls = 'ability-hint' | ||
if m.disabled then cls = cls .. ' ability-hint--disabled' end | |||
return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor) | |||
if m. | .. '<span class="ability-hint-tip">' .. m.title .. ' Interaction. Click to see more</span></span>' | ||
return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor | |||
.. '<span class="ability-hint-tip">' .. | |||
end | end | ||
| Line 101: | Line 40: | ||
manual = manual or {} | manual = manual or {} | ||
local | -- Files claimed by a manual icon suppress the matching automatic icon. | ||
local manual_files = {} | |||
for _, m in ipairs(manual) do | for _, m in ipairs(manual) do | ||
manual_files[mw.ustring.lower(m.file)] = true | |||
end | end | ||
local | local icons = {} | ||
local num = tonumber(ability_num) | 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( | table.insert(icons, hint_icon(def)) | ||
end | end | ||
end | end | ||
| Line 124: | Line 60: | ||
for _, m in ipairs(manual) do | for _, m in ipairs(manual) do | ||
table.insert(icons, manual_icon(m)) | |||
end | end | ||
if # | if #icons == 0 then return '' end | ||
return '<div class="ability-section-hints">' .. table.concat(icons) .. '</div>' | return '<div class="ability-section-hints">' .. table.concat(icons) .. '</div>' | ||
end | end | ||
return p | return p | ||