Module:AbilityHints: Difference between revisionsGive feedback
mNo edit summary |
Replace the reactive/indomitable split icon with a grouped single icon whose image and tooltip depend on which of the two lists match (with help from vergir-bot LLM) |
||
| Line 10: | Line 10: | ||
local p = {} | local p = {} | ||
-- Display order. Each entry: | -- Display order. Each entry is either: | ||
-- list | -- { list = "...", item = "...", tip = "..." } a single icon shown when the ability is in `list` | ||
-- { group = "..." } a grouped relationship (see GROUPS) | |||
-- | |||
local CONFIG = { | local CONFIG = { | ||
{ list = "melee", item = "Melee Lifesteal", tip = "Benefits from melee items" }, | { list = "melee", item = "Melee Lifesteal", tip = "Benefits from melee items" }, | ||
| Line 20: | Line 18: | ||
{ list = "debuffresist", item = "Debuff Reducer", tip = "Duration reduced by Debuff Resist" }, | { list = "debuffresist", item = "Debuff Reducer", tip = "Duration reduced by Debuff Resist" }, | ||
{ list = "heal", item = "Healing Booster", tip = "Healing amplified by Healing Booster and affected by healing reduction" }, | { list = "heal", item = "Healing Booster", tip = "Healing amplified by Healing Booster and affected by healing reduction" }, | ||
{ | { group = "reactive_indomitable" }, | ||
{ list = "dispelmagic", item = "Dispel Magic", tip = "Effect can be dispelled" }, | { list = "dispelmagic", item = "Dispel Magic", tip = "Effect can be dispelled" }, | ||
{ list = "unstoppable", item = "Unstoppable", tip = "Disable prevented by Unstoppable" }, | { list = "unstoppable", item = "Unstoppable", tip = "Disable prevented by Unstoppable" }, | ||
{ list = "platedarmor", item = "Plated Armor", tip = "On-shot effect prevented by Plated Armor" }, | { list = "platedarmor", item = "Plated Armor", tip = "On-shot effect prevented by Plated Armor" }, | ||
} | } | ||
-- | -- Grouped relationships: two related lists collapse into ONE full-size icon | ||
-- the | -- whose item and tooltip depend on which of the two the ability matches. | ||
local GROUPS = { | |||
local | reactive_indomitable = { | ||
{ "reactivebarrier", "indomitable" }, | a = "reactivebarrier", | ||
b = "indomitable", | |||
a_only = { item = "Reactive Barrier", tip = "Triggers Reactive Barrier<br>does <b>not</b> trigger Indomitable" }, | |||
b_only = { item = "Indomitable", tip = "Blocked by Indomitable<br>does <b>not</b> trigger Reactive Barrier" }, | |||
both = { item = "Reactive Barrier", tip = "Triggers Reactive Barrier<br>Blocked by Indomitable" }, | |||
}, | |||
} | } | ||
-- Renders one item icon as a title-less external link (so Page Previews / Popups | -- Renders one item icon as a title-less external link (so Page Previews / Popups | ||
| Line 46: | Line 43: | ||
end | end | ||
-- | -- One full-size hint icon with a tooltip. | ||
local function hint_icon(item, tip) | |||
return '<span class="ability-hint">' .. icon_img(item) | |||
.. '<span class="ability-hint-tip">' .. tip .. '</span></span>' | |||
local function | |||
return '<span class="ability-hint | |||
.. '<span class="ability-hint-tip">' . | |||
end | end | ||
| Line 71: | Line 58: | ||
local num = tonumber(ability_num) | local num = tonumber(ability_num) | ||
-- Membership for every list referenced by CONFIG or GROUPS. | |||
local member = {} | local member = {} | ||
local function check(list) | |||
if list ~= nil and member[list] == nil then | |||
member[list] = AbilityTable.is_member(list, record, num) | |||
end | |||
end | |||
for _, def in ipairs(CONFIG) do | for _, def in ipairs(CONFIG) do | ||
if def.list then | |||
check(def.list) | |||
elseif def.group then | |||
local g = GROUPS[def.group] | |||
check(g.a) | |||
check(g.b) | |||
end | end | ||
end | end | ||
| Line 90: | Line 77: | ||
local icons = {} | local icons = {} | ||
for _, def in ipairs(CONFIG) do | for _, def in ipairs(CONFIG) do | ||
if | if def.group then | ||
local g = GROUPS[def.group] | |||
if | local ma, mb = member[g.a], member[g.b] | ||
local case | |||
if ma and mb then | |||
table.insert(icons, | case = g.both | ||
elseif ma then | |||
case = g.a_only | |||
elseif mb then | |||
case = g.b_only | |||
end | |||
if case then | |||
table.insert(icons, hint_icon(case.item, case.tip)) | |||
end | end | ||
elseif def.list and member[def.list] then | |||
table.insert(icons, hint_icon(def.item, def.tip)) | |||
end | end | ||
end | end | ||