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 resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json") | ||
local item_data = mw.loadJsonData("Data:ItemData.json") | local item_data = mw.loadJsonData("Data:ItemData.json") | ||
| Line 37: | Line 9: | ||
local p = {} | local p = {} | ||
-- Display order: item | -- Automatic hints that get shown without corresponding {{AbilityInteraction}}. Powered by Module:AbilityTable | ||
local CONFIG = { | |||
{ list = "melee", file = "Melee Lifesteal.png", tip = "Benefits from melee items (e.g. [[Melee Lifesteal]])" }, | |||
{ list = "dontbreakstealth", file = "Veil Walker.png", tip = "Casting does not break stealth from [[Veil Walker]] or [[Shadow Weave]]" }, | |||
{ list = "movementbased", file = "Slowing Hex.png", tip = "Disabled by [[Slowing Hex]]" }, | |||
{ list = "debuffresist", file = "Debuff Reducer.png", tip = "Debuff duration reduced by [[Debuff Resist]]" }, | |||
{ list = "heal", file = "Healing Booster.png", tip = "Healing amplified by [[Healing Booster]] and affected by healing reduction" }, | |||
{ list = "healingtempo", file = "Healing Tempo.png", tip = "Healing triggers [[Healing Tempo]]'s unique effect" }, | |||
{ list = "reactivebarrier", file = "Reactive Barrier.png", tip = "Triggers [[Reactive Barrier]]" }, | |||
{ list = "dispelmagic", file = "Dispel Magic.png", tip = "Effect can be [[Dispel Magic|dispelled]]" }, | |||
{ list = "indomitable", file = "Indomitable.png", tip = "Disable prevented by [[Indomitable]]" }, | |||
{ list = "unstoppable", file = "Unstoppable.png", tip = "Negative status effects suppressed by [[Unstoppable]]" }, | |||
{ list = "platedarmor", file = "Plated Armor.png", tip = "On-shot effect prevented by [[Plated Armor]]" }, | |||
{ list = "summons", file = "Monster Rounds.png", tip = "Summons affected by [[Monster Rounds]] and [[Heroic Aura]]" }, | |||
} | |||
-- Display order: item slot (Weapon, then Vitality, then Spirit), then cost, then name. | |||
local function sort_key(file) | local function sort_key(file) | ||
local base = mw.ustring.lower((file:gsub('%.%w+$', ''))) | local base = mw.ustring.lower((file:gsub('%.%w+$', ''))) | ||
| Line 76: | Line 64: | ||
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) | ||
.. '<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' | ||
local | local verb = 'Interacts with' | ||
local partial = false | local partial = false | ||
if m.state == 'disabled' then | if m.state == 'disabled' then | ||
cls = cls .. ' ability-hint--disabled' | cls = cls .. ' ability-hint--disabled' | ||
verb = 'Does not interact with' | |||
elseif m.state == 'partial' then | elseif m.state == 'partial' then | ||
verb = 'Interacts partially with' | |||
partial = true | partial = true | ||
end | end | ||
return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor, partial) | return '<span class="' .. cls .. '">' .. icon_img(m.file, '#' .. m.anchor, partial) | ||
.. '<span class="ability-hint-tip">' .. | .. '<span class="ability-hint-tip">' .. verb .. ' ' .. m.title .. '.<br>Click to reveal more info.</span></span>' | ||
end | end | ||
| Line 109: | Line 93: | ||
local placed = {} | local placed = {} | ||
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) then | |||
local key = mw.ustring.lower(def.file) | |||
local m = manual_by_file[key] | |||
if m ~= nil then | |||
table.insert(entries, { file = m.file, html = manual_icon(m) }) | |||
placed[key] = true | |||
else | |||
table.insert(entries, { file = def.file, html = hint_icon(def) }) | |||
end | |||
end | end | ||
end | end | ||