Module:AbilityHints: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Create Module:AbilityHints: small item interaction icons for ability cards, membership driven by AbilityTable.is_member (with help from vergir-bot LLM) |
mNo edit summary |
||
| Line 16: | Line 16: | ||
-- suppressed_by optional: hide this icon when the named list is also a member | -- suppressed_by optional: hide this icon when the named list is also a member | ||
local CONFIG = { | local CONFIG = { | ||
{ list = "dispelmagic", item = "Dispel Magic", tip = " | { list = "dispelmagic", item = "Dispel Magic", tip = "Effect can be dispelled by Dispel Magic" }, | ||
{ list = "debuffresist", item = "Debuff Reducer", tip = "Duration reduced by Debuff Reducer" }, | { list = "debuffresist", item = "Debuff Reducer", tip = "Duration reduced by Debuff Reducer" }, | ||
{ list = "divinebarrier", item = "Divine Barrier", tip = " | { list = "divinebarrier", item = "Divine Barrier", tip = "Effect can be dispelled by Divine Barrier", suppressed_by = "dispelmagic" }, | ||
{ list = "reactivebarrier", item = "Reactive Barrier", tip = "Blocked by Reactive Barrier" }, | { list = "reactivebarrier", item = "Reactive Barrier", tip = "Blocked by Reactive Barrier" }, | ||
{ list = " | { list = "indomitable", item = "Indomitable", tip = "Duration reduced by Indomitable", suppressed_by = "reactivebarrier" }, | ||
{ list = " | { list = "unstoppable", item = "Unstoppable", tip = "Prevented by Unstoppable" }, | ||
{ list = "cursedrelic", item = "Cursed Relic", tip = "Interrupted by Cursed Relic" }, | { list = "cursedrelic", item = "Cursed Relic", tip = "Interrupted by Cursed Relic" }, | ||
{ list = "platedarmor", item = "Plated Armor", tip = " | { list = "platedarmor", item = "Plated Armor", tip = "Prevented by Plated Armor" }, | ||
{ list = "movementbased", item = "Slowing Hex", tip = "Disabled by Slowing Hex" }, | { list = "movementbased", item = "Slowing Hex", tip = "Disabled by Slowing Hex" }, | ||
{ list = "charges", item = "Rapid Recharge", tip = " | { list = "charges", item = "Rapid Recharge", tip = "Charged ability" }, | ||
{ list = "heal", item = "Healing Booster", tip = "Amplified by Healing Booster" }, | { list = "heal", item = "Healing Booster", tip = "Amplified by Healing Booster" }, | ||
{ list = "melee", item = "Melee Lifesteal", tip = "Benefits from Melee | { list = "melee", item = "Melee Lifesteal", tip = "Benefits from Melee Damage" }, | ||
} | } | ||
Revision as of 09:22, 12 July 2026
Overview
Renders a small strip of item icons showing how an ability interacts with items and used by Module:AbilitySection. Each icon displays a configured image and has a hover tooltip.
Hints can be "automatic" and "manual".
- Automatic come from Module:AbilityTable/Lists. If an ability is part of 'debuffresist' list, then it will show automatic debuff resist hint. List of enabled automatic hints is configured through CONFIG in this module. Clicking on an icon does nothing, however tooltip often will have a link to relevant item/mechanic.
- Manual hints come from
{{AbilityInteraction}}blocks used on AbilitySection. Whenetever an editor describes an interaction using that block a hint will be displayed. Clicking on a hint reveals that hand-written block.
Entry point
p.get_icons(ability_key, ability_num)
Returns the rail HTML for one ability, or an empty string when the ability matches no lists.
Configuration
CONFIG
List of the icons the rail can show. Order within CONFIG does not affect the rendered output — see Display order. Each entry:
| Field | Description |
|---|---|
list |
List name in Module:AbilityTable/Lists whose membership triggers the icon. |
file |
Image file to display, e.g. Reactive Barrier.png. Also determines the icon's position in the rail.
|
tip |
Hover tooltip text. May contain wikilinks and simple HTML (<br>, <b>).
|
To add an icon, add a CONFIG row: pick the triggering list, the display file, and the tip. To re-scope which abilities an icon covers, edit the list in Module:AbilityTable/Lists.
-- Ability interaction hints: small item icons on ability cards showing how an
-- ability interacts with items (dispellable, reduced, blocked, etc.).
-- Membership is decided by Module:AbilityTable.is_member so these icons always
-- agree with the dynamic ability-interaction tables.
local AbilityTable = require("Module:AbilityTable")
local icon_module = require("Module:Icon")
local ability_data = mw.loadJsonData("Data:AbilityData.json")
local p = {}
-- Display order. Each entry:
-- list AbilityTable list name (Module:AbilityTable/Lists)
-- item item whose icon represents the interaction
-- tip short hover text
-- suppressed_by optional: hide this icon when the named list is also a member
local CONFIG = {
{ list = "dispelmagic", item = "Dispel Magic", tip = "Effect can be dispelled by Dispel Magic" },
{ list = "debuffresist", item = "Debuff Reducer", tip = "Duration reduced by Debuff Reducer" },
{ list = "divinebarrier", item = "Divine Barrier", tip = "Effect can be dispelled by Divine Barrier", suppressed_by = "dispelmagic" },
{ list = "reactivebarrier", item = "Reactive Barrier", tip = "Blocked by Reactive Barrier" },
{ list = "indomitable", item = "Indomitable", tip = "Duration reduced by Indomitable", suppressed_by = "reactivebarrier" },
{ list = "unstoppable", item = "Unstoppable", tip = "Prevented by Unstoppable" },
{ list = "cursedrelic", item = "Cursed Relic", tip = "Interrupted by Cursed Relic" },
{ list = "platedarmor", item = "Plated Armor", tip = "Prevented by Plated Armor" },
{ list = "movementbased", item = "Slowing Hex", tip = "Disabled by Slowing Hex" },
{ list = "charges", item = "Rapid Recharge", tip = "Charged ability" },
{ list = "heal", item = "Healing Booster", tip = "Amplified by Healing Booster" },
{ list = "melee", item = "Melee Lifesteal", tip = "Benefits from Melee Damage" },
}
-- Renders the interaction icon rail for one ability.
-- ability_key the ability's internal key (AbilityCards .Key)
-- ability_num the ability's slot (1-4); coerced to number
-- Returns rail HTML, or '' when the ability has no interactions.
function p.get_icons(ability_key, ability_num)
local record = ability_data[ability_key]
if record == nil then return '' end
local num = tonumber(ability_num)
local member = {}
for _, def in ipairs(CONFIG) do
member[def.list] = AbilityTable.is_member(def.list, record, num)
end
local icons = {}
for _, def in ipairs(CONFIG) do
if member[def.list] and not (def.suppressed_by and member[def.suppressed_by]) then
local img = icon_module._render(def.item, { size = '24px', ['icon-only'] = 'true' })
table.insert(icons,
'<span class="ability-hint">' .. img
.. '<span class="ability-hint-tip">' .. def.tip .. '</span></span>'
)
end
end
if #icons == 0 then return '' end
return '<div class="ability-section-hints">' .. table.concat(icons) .. '</div>'
end
return p