Module:AbilityHints: Difference between revisionsGive feedback
Jump to navigation
Jump to search
mNo edit summary |
Replace reactivebarrier/indomitable suppression with a diagonally-split combined icon (clip-path); tooltip shows both notes (with help from vergir-bot LLM) |
||
| Line 22: | Line 22: | ||
{ 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" }, | ||
{ list = "dispelmagic", item = "Dispel Magic", tip = "Effect can be dispelled" }, | { list = "dispelmagic", item = "Dispel Magic", tip = "Effect can be dispelled" }, | ||
{ list = "indomitable", item = "Indomitable", tip = "Effect blocked by Indomitable | { list = "indomitable", item = "Indomitable", tip = "Effect blocked by Indomitable" }, | ||
{ list = "unstoppable", item = "Unstoppable", tip = "Disable prevented by Unstoppable" }, | { list = "unstoppable", item = "Unstoppable", tip = "Disable prevented by Unstoppable" }, | ||
{ list = "platedarmor", item = "Plated Armor", tip = "Bullet effect prevented by Plated Armor" }, | { list = "platedarmor", item = "Plated Armor", tip = "Bullet effect prevented by Plated Armor" }, | ||
} | } | ||
-- Pairs that merge into ONE diagonally-split icon when BOTH match the ability: | |||
-- the first list fills the upper-left triangle, the second the lower-right. | |||
-- (Replaces suppressed_by for these pairs.) | |||
local COMBINE = { | |||
{ "reactivebarrier", "indomitable" }, | |||
} | |||
local DEF_BY_LIST = {} | |||
for _, def in ipairs(CONFIG) do | |||
DEF_BY_LIST[def.list] = def | |||
end | |||
-- Renders one item icon as a title-less external link (so Page Previews / Popups | |||
-- ignores it) wrapping just the image. | |||
local function icon_img(item) | |||
local url = tostring(mw.uri.canonicalUrl(item)) | |||
return icon_module._render(item, { size = '24px', ['icon-only'] = 'true', link = url }) | |||
end | |||
-- A normal single hint icon. | |||
local function single_icon(def) | |||
return '<span class="ability-hint">' .. icon_img(def.item) | |||
.. '<span class="ability-hint-tip">' .. def.tip .. '</span></span>' | |||
end | |||
-- A combined icon split along the diagonal: tl = upper-left, br = lower-right. | |||
-- Each half links to its own item; the tooltip lists both notes. | |||
local function split_icon(tl, br) | |||
return '<span class="ability-hint ability-hint--split">' | |||
.. '<span class="ability-hint-half ability-hint-half--tl">' .. icon_img(tl.item) .. '</span>' | |||
.. '<span class="ability-hint-half ability-hint-half--br">' .. icon_img(br.item) .. '</span>' | |||
.. '<span class="ability-hint-tip">' .. tl.tip .. '<br>' .. br.tip .. '</span>' | |||
.. '</span>' | |||
end | |||
-- Renders the interaction icon rail for one ability. | -- Renders the interaction icon rail for one ability. | ||
| Line 39: | Line 74: | ||
for _, def in ipairs(CONFIG) do | for _, def in ipairs(CONFIG) do | ||
member[def.list] = AbilityTable.is_member(def.list, record, num) | member[def.list] = AbilityTable.is_member(def.list, record, num) | ||
end | |||
-- Resolve combos: when both lists match, the second is consumed and drawn as | |||
-- the lower-right half of the first list's icon. | |||
local split_with = {} | |||
local consumed = {} | |||
for _, c in ipairs(COMBINE) do | |||
local tl, br = c[1], c[2] | |||
if member[tl] and member[br] then | |||
split_with[tl] = br | |||
consumed[br] = true | |||
end | |||
end | end | ||
local icons = {} | local icons = {} | ||
for _, def in ipairs(CONFIG) do | for _, def in ipairs(CONFIG) do | ||
if member[def.list] and not (def.suppressed_by and member[def.suppressed_by]) then | if member[def.list] and not consumed[def.list] | ||
and not (def.suppressed_by and member[def.suppressed_by]) then | |||
if split_with[def.list] then | |||
table.insert(icons, split_icon(def, DEF_BY_LIST[split_with[def.list]])) | |||
else | |||
table.insert(icons, | table.insert(icons, single_icon(def)) | ||
end | |||
end | end | ||
end | end | ||