Module:ItemData/nav: Difference between revisionsGive feedback
Gammaton32 (talk | contribs) added override for Bullet Lifesteal and Spirit Lifesteal in ItemBox |
Gammaton32 (talk | contribs) changed displayed cost for Legendary items in ItemBox list (needs to be changed for Active table as well) |
||
| Line 77: | Line 77: | ||
if lang_code == "en" then | if lang_code == "en" then | ||
-- For English pages, do not include item_loc or link | -- For English pages, do not include item_loc or link | ||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|link=" .. item_link .. "}}" | -- Display cost as "Legendary" for street brawl items | ||
if is_street_brawl == true then | |||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|link=" .. item_link .. "|item_price=Legendary" .. "}}" | |||
else | |||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|link=" .. item_link .. "}}" | |||
end | |||
else | else | ||
-- For non-English pages, include item_loc and link | -- For non-English pages, include item_loc and link | ||
local link_local = item_link .. "/" .. lang_code -- Add subpage for non-English languages | local link_local = item_link .. "/" .. lang_code -- Add subpage for non-English languages | ||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link_local .. "}}" | if is_street_brawl == true then | ||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link_local .. | |||
"|item_price={{#invoke:Lang|get_string|Citadel_ItemDraft_Legendary}}" .. "}}" | |||
else | |||
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link_local .. "}}" | |||
end | |||
end | end | ||
else | else | ||
Revision as of 19:39, 23 April 2026
Overview
Functions for creating navigation boxes/lists for items, grouped by a slot/category and souls. Supports filtering for Street Brawl items.
Functions
get_item_nav_bulletpoints
Gets a list of items that are each sent to the Template:ItemIcon template, separated by bullet points.
Filters down to a slot/specific category, and within a range of souls. Can optionally filter for Street Brawl items.
Parameters
- slot - Slot/category that the items should be, should be Weapon, Armor, or Tech
- min_souls - Minimum souls that the items should have
- max_souls - Maximum souls that the items should have (Note: the command does not include items equal to this value, so in order to include them it should be written as
cost + 1) - debug_mode - (OPTIONAL) - if set to 'true', the wikitext is unprocessed, allowing for it to be read more clearly. Also used for showcasing the documentation examples more clearly.
- filter - (OPTIONAL) - Filters items based on Street Brawl status. Options:
exclude_street_brawl(show only regular items),street_brawl_only(show only Street Brawl items), or unset (show all)
Examples
With debug_mode on (for illustration purposes)
{{#invoke:ItemData/nav|get_item_nav_bulletpoints|Armor|1250|3000|debug_mode=true}}
{{ItemIcon|Battle Vest}} • {{ItemIcon|Bullet Lifesteal}} • {{ItemIcon|Debuff Reducer}} • {{ItemIcon|Enchanter's Emblem}} • {{ItemIcon|Enduring Speed}} • {{ItemIcon|Guardian Ward}} • {{ItemIcon|Healbane}} • {{ItemIcon|Healing Booster}} • {{ItemIcon|Reactive Barrier}} • {{ItemIcon|Restorative Locket}} • {{ItemIcon|Return Fire}} • {{ItemIcon|Spirit Lifesteal}} • {{ItemIcon|Spirit Shielding}} • {{ItemIcon|Trophy Collector}} • {{ItemIcon|Weapon Shielding}}
With debug_mode off
{{#invoke:ItemData/nav|get_item_nav_bulletpoints|Armor|1250|3000}}
Battle Vest • Bullet Lifesteal • Debuff Reducer • Enchanter's Emblem • Enduring Speed • Guardian Ward • Healbane • Healing Booster • Reactive Barrier • Restorative Locket • Return Fire • Spirit Lifesteal • Spirit Shielding • Trophy Collector • Weapon Shielding
To include the 3000 items
{{#invoke:ItemData/nav|get_item_nav_bulletpoints|Armor|1250|3001}}
Battle Vest • Bullet Lifesteal • Debuff Reducer • Enchanter's Emblem • Enduring Speed • Guardian Ward • Healbane • Healing Booster • Reactive Barrier • Restorative Locket • Return Fire • Spirit Lifesteal • Spirit Shielding • Trophy Collector • Weapon Shielding
get_item_nav_cards
Gets a list of items that are each sent to the Template:ItemBox template, separated by space.
Filters down to a specific slot/category, and within a range of souls. Can optionally filter for Street Brawl items.
Parameters
Same as get_item_nav_bulletpoints
Examples
With debug_mode on (for illustration purposes)
{{#invoke:ItemData/nav|get_item_nav_bulletpoints|Armor|1250|3000|debug_mode=true}}
{{ItemBox|item_name=Battle Vest|link=Battle Vest}} {{ItemBox|item_name=Bullet Lifesteal|link=Bullet Lifesteal (item)}} {{ItemBox|item_name=Debuff Reducer|link=Debuff Reducer}} {{ItemBox|item_name=Enchanter's Emblem|link=Enchanter's Emblem}} {{ItemBox|item_name=Enduring Speed|link=Enduring Speed}} {{ItemBox|item_name=Guardian Ward|link=Guardian Ward}} {{ItemBox|item_name=Healbane|link=Healbane}} {{ItemBox|item_name=Healing Booster|link=Healing Booster}} {{ItemBox|item_name=Reactive Barrier|link=Reactive Barrier}} {{ItemBox|item_name=Restorative Locket|link=Restorative Locket}} {{ItemBox|item_name=Return Fire|link=Return Fire}} {{ItemBox|item_name=Spirit Lifesteal|link=Spirit Lifesteal (item)}} {{ItemBox|item_name=Spirit Shielding|link=Spirit Shielding}} {{ItemBox|item_name=Trophy Collector|link=Trophy Collector}} {{ItemBox|item_name=Weapon Shielding|link=Weapon Shielding}}
With debug_mode off
{{#invoke:ItemData/nav|get_item_nav_bulletpoints|Armor|1250|3000}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
<div class="itembox itembox-tier-Item Not Found. itembox-icon-v3 itembox-wear-v3 itembox-texture-v2 " style="font-size:10px;">
{{{1}}}
write_item_slot_subgroup
Writes a sub group for the navbox on Template:Item Navbox and Template:Infobox ShopItems. The sub group contains all items in each price range from "ItemPricePerTier" in Data:GenericData.json. Street Brawl items are automatically separated into their own row at the end.
Parameters
- slot - Slot/category to create the subgroup for, ie Weapon, Armor, or Tech
- type - The subfunction to call that determines the list formatting style. Options are 'get_item_nav_bulletpoints' or 'get_item_nav_cards'
- debug_mode - (OPTIONAL) - if set to 'true', the wikitext is unprocessed, allowing for it to be read more clearly. Also used for showcasing the documentation examples more clearly.
- street_brawl_label - (OPTIONAL) - Custom label text for the Street Brawl row. Defaults to "Street Brawl"
Examples
With debug_mode on (for illustration purposes)
{{#invoke:ItemData/nav|write_item_slot_subgroup|Weapon|get_item_nav_bulletpoints|debug_mode=true}}
{{ItemIcon|Close Quarters}} • {{ItemIcon|Extended Magazine}} • {{ItemIcon|Headshot Booster}} • {{ItemIcon|High-Velocity Rounds}} • {{ItemIcon|Monster Rounds}} • {{ItemIcon|Rapid Rounds}} • {{ItemIcon|Restorative Shot}} | |
{{ItemIcon|Active Reload}} • {{ItemIcon|Fleetfoot}} • {{ItemIcon|Intensifying Magazine}} • {{ItemIcon|Kinetic Dash}} • {{ItemIcon|Long Range}} • {{ItemIcon|Melee Charge}} • {{ItemIcon|Mystic Shot}} • {{ItemIcon|Opening Rounds}} • {{ItemIcon|Recharging Rush}} • {{ItemIcon|Slowing Bullets}} • {{ItemIcon|Spirit Shredder Bullets}} • {{ItemIcon|Split Shot}} • {{ItemIcon|Stalker}} • {{ItemIcon|Swift Striker}} • {{ItemIcon|Titanic Magazine}} • {{ItemIcon|Weakening Headshot}} | |
{{ItemIcon|Alchemical Fire}} • {{ItemIcon|Ballistic Enchantment}} • {{ItemIcon|Berserker}} • {{ItemIcon|Blood Tribute}} • {{ItemIcon|Burst Fire}} • {{ItemIcon|Cultist Sacrifice}} • {{ItemIcon|Escalating Resilience}} • {{ItemIcon|Express Shot}} • {{ItemIcon|Headhunter}} • {{ItemIcon|Heroic Aura}} • {{ItemIcon|Hollow Point}} • {{ItemIcon|Hunter's Aura}} • {{ItemIcon|Point Blank}} • {{ItemIcon|Shadow Weave}} • {{ItemIcon|Sharpshooter}} • {{ItemIcon|Spirit Rend}} • {{ItemIcon|Tesla Bullets}} • {{ItemIcon|Toxic Bullets}} • {{ItemIcon|Weighted Shots}} | |
{{ItemIcon|Armor Piercing Rounds}} • {{ItemIcon|Capacitor}} • {{ItemIcon|Crippling Headshot}} • {{ItemIcon|Crushing Fists}} • {{ItemIcon|Frenzy}} • {{ItemIcon|Glass Cannon}} • {{ItemIcon|Lucky Shot}} • {{ItemIcon|Ricochet}} • {{ItemIcon|Silencer}} • {{ItemIcon|Spellslinger}} • {{ItemIcon|Spiritual Overflow}} | |
{{ItemIcon|Haunting Shot}} • {{ItemIcon|Infinite Rounds}} • {{ItemIcon|Runed Gauntlets}} |
With debug_mode off
{{#invoke:ItemData/nav|write_item_slot_subgroup|Weapon|get_item_nav_bulletpoints}}
Recall that it creates subgroup parameters for the mentioned templates.
generate_active_items_table
Creates table of localized released active items. Used in Template:Active Items
Example
{{#invoke:ItemData/nav|generate_active_items_table}}
| Name | Type | Active | Cooldown | ||
|---|---|---|---|---|---|
| Alchemical Fire | Throw a flask that explodes on contact, creating an area that does increasing 50% less effective vs non-heroes. |
30s | |||
| Arctic Blast | Release an expanding ice blast that deals Slowed targets have their stamina regen frozen |
24s | |||
| Blood Tribute | Toggle: Continually sacrifice Health to improve |
s | |||
| Capacitor | Launch a projectile that deals |
40s | |||
| Celestial Blessing | Applies an extremely powerful cleanse that replenishes your allies globally. | 30s | |||
| Cold Front | Release an expanding ice blast that deals |
25s | |||
| Colossus | Grow larger in size, gaining Nearby enemies suffer from |
37s | |||
| Cultist Sacrifice | Target an enemy NPC and consume it for 180% Bonus Souls and grants a powerful long lasting buff. | 270s | |||
| Cursed Relic | Curses an enemy - interrupting, Silencing, Disarming, and preventing item usage. Removes all non-ultimate buffs. Your own Damage Output is reduced for the duration. |
55s | |||
| Decay | Inflict damage over time to a target, dealing damage based on their current health. Decay's damage is non-lethal and does not apply item procs. |
30s | |||
| Disarming Hex | Disarms enemy target and reduces their Bullet Resist. | 16s | |||
| Dispel Magic | Purge all non-ultimate negative effects currently applied to you. If any effects were removed, heal yourself and gain a move speed bonus. Cannot be used while Stunned or Slept. |
45s | |||
| Divine Barrier | Remove all non-stun debuffs from the target and provide them with a Barrier and Move Speed. Can be self-cast. Cooldown is reduced by half when cast on someone else. |
45s | |||
| Echo Shard | Reset the cooldown of the imbued non-ultimate ability. This item's cooldown is increased by the cooldown of the imbued ability. |
30s | |||
| Ethereal Shift | You enter a void state and become untargetable and invincible for a short duration, during which you float slowly and cannot perform actions. Afterwards you gain Spirit Power, Move Speed, and Spirit Resist. Can be canceled early. Activation cancels any active ability. |
37s | |||
| Fleetfoot | Gain bonus Move Speed and Slow Resistance. | 16s | |||
| Focus Lens | Target an enemy to Silence them. A portion of all damage dealt during the silence gets applied to the target when the silence wears off. | 45s | |||
| Fury Trance | Grants Fire Rate, Spirit Resistance and Move Speed, and removes the Move Speed penalty while shooting, but Silences you and disables stamina usage and regeneration. | 18s | |||
| Golden Goose Egg | Hatch the egg, gaining souls and permanent buffs. The value of the egg grows the longer you hold onto it. Gain a permanent buff per 80 Souls accrued when hatched.Gain souls over time, as long as you are alive. |
s | |||
| Grit | Gain a Barrier for a short duration. | 60s | |||
| Guardian Ward | Provide the target with a Barrier and temporary Move Speed. Can be self-cast. Cooldown is reduced by half when cast on someone else. |
60s | |||
| Healing Nova | Heal yourself and nearby allies. | 60s | |||
| Healing Rite | Grant Regen and Sprint Speed to the target. Gets dispelled if you take damage from enemy players or objectives. Can be self-cast. | 70s | |||
| Heroic Aura | Provides |
22s | |||
| Infuser | Gain Spirit Lifesteal and Spirit Power. | 30s | |||
| Knockdown | Apply a Stun after 2s. Stun duration is increased against airborne targets. Increases the target's gravity for the duration of the stun. |
35s | |||
| Magic Carpet | Summon a Magic Carpet that will fly you away. While flying you are immune to slows and doing any action will dismiss the carpet. Cannot use abilities while the carpet is being summoned. |
32s | |||
| Majestic Leap | Launch yourself high into the air and grant yourself a Barrier. While in the air, you can use the active again to drop down faster. Cannot be used for 5s if attacked by enemy Hero. |
45s | |||
| Metal Skin | Become immune to bullets. | 24s | |||
| Mystical Piano | After a short delay, enemies in the target area will be stunned and have their stamina depleted. After the stun they will be temporarily dazed. | 23s | |||
| Nullification Burst | Removes any positive buffs and prevents stamina usage and healing effects on enemies. | 18s | |||
| Phantom Strike | Teleport to an enemy target and pull them to the ground. Dealing damage, Move speed reduction and Disarm. | 35s | |||
| Prism Blast | You enter a void state and become untargetable and invincible for a short duration, during which lasers blast out and rotate around you. | 40s | |||
| Refresher | Reset the cooldown of all your abilities and restore all your charges. | 300s | |||
| Rescue Beam | Heals a target allied hero and yourself for a percentage of Max Health. Once while healing, you can Pull the target towards you. Can be self-cast. | 60s | |||
| Restorative Locket | When an enemy uses an ability within 35m range from you, store one Restoration Stack. Consume all stacks to heal yourself and replenish up to 3 stamina based on how many stacks you have. |
20s | |||
| Return Fire | Automatically fire a bullet towards any attacker who damages you with their abilities or weapon. | 23s | |||
| Rusted Barrel | Target an enemy to reduce their Fire Rate and Bullet Resistance. | 16s | |||
| Scourge | Apply Spirit Resist, Debuff Resist and an aura on a friendly target that deals Can be self cast. |
35s | |||
| Shadow Weave | Become Stealthed. Whenever you take damage while Stealthed you get briefly revealed. | 45s | |||
| Shrink Ray | Reduces Model Size and grants Move Speed to the target. Allows usage of tunnels in this mode. Can be self-cast. | 30s | |||
| Silence Wave | Launch an expanding projectile which Silences enemies for a short duration and deals impact damage. Silence does not interrupt channeling abilities. |
42s | |||
| Slowing Hex | Slows movement of enemy target. Also Silences their movement-based items and abilities. Increases the target's gravity. Does not affect target's stamina usage. |
27s | |||
| Spirit Sap | Target an enemy to reduce their Spirit Resist and Spirit Power. | 18s | |||
| Split Shot | Make your weapon fire multishot. Hitting more than one Hero per attack will grant a stacking weapon damage bonus. Targets can only be hit once per multishot. |
27s | |||
| Unstable Concoction | Consume a concoction that grants you Unstoppable and increased speed, health, spirit and weapon damage. After a short duration you die and explode, stunning nearby enemies and dealing damage based on your maximum health. Dying this way reduces your respawn time by 50%. | 25s | |||
| Unstoppable | Temporarily suppress negative status effects and become immune to Stun, Silence, Sleep, Root, and Disarm. Cannot be used while Stunned or Slept. |
60s | |||
| Vampiric Burst | Grants Lifesteal, Fire Rate, and Ammo. This added Ammo is not limited by your max magazine size. | 30s | |||
| Vortex Web | Throw a vacuum grenade, pulling all enemies into a small area and applying Slowing Hex. Alt Cast to Target Unit Directly. |
42s | |||
| Warp Stone | Teleport straight ahead, gaining Bullet Resist. | 16s | |||
local p = {}
local items_data = mw.loadJsonData("Data:ItemData.json")
local lang_module = require('Module:Lang')
local generic_module = require('Module:GenericData')
local util_module = require('Module:Utilities')
--exceptions if the link is different from the item name
local linkOverrides = {
["Bullet Lifesteal"] = "Bullet Lifesteal (item)",
["Spirit Lifesteal"] = "Spirit Lifesteal (item)"
}
--With debug_mode on, it outputs unprocessed wikitext
--With debug_mode off/unspecified, it processes the wikitext
local function process_debug_mode(wikitext, debug_mode)
if debug_mode == 'true' then
return wikitext
elseif debug_mode == 'false' or debug_mode == nil then
return mw.getCurrentFrame():preprocess(wikitext)
else
return "debug_mode must be 'true' or 'false'"
end
end
--Writes list of items of a certain slot within the min and max soul bounds
-- Each item is wrapped and separated. For example of wrapping/separator, see
-- get_item_nav_bulletpoints. 'sep' should not be combined with 'right_wrap',
-- as the trailing separator should also be removed from the string
-- filter_mode parameter: nil/"all", "exclude_street_brawl", or "street_brawl_only"
local function write_wrapped_item_list(slot, min_souls, max_souls, template, sep, filter_mode)
if slot ~= 'Weapon' and slot ~= 'Armor' and slot ~= 'Tech' then
return 'slot must be Weapon, Armor (Vitality), or Tech (Spirit)'
end
local min_souls = tonumber(min_souls)
local max_souls = tonumber(max_souls)
if min_souls == nil or max_souls == nil then return 'Min/Max souls must be numerical' end
-- Normalize filter_mode to handle unset parameter
filter_mode = filter_mode or "all"
-- Retrieve all items that fit the bounds and filter criteria
local items = {}
for item_key, item_data in pairs(items_data) do
-- future proofing; Disabled will be renamed to IsDisabled soon
local this_cost = tonumber(item_data["Cost"])
local this_slot = item_data["Slot"]
-- Filter logic for Street Brawl items
local is_street_brawl = item_data["StreetBrawl"] == true
local should_include = true
if filter_mode == "street_brawl_only" and not is_street_brawl then
should_include = false
elseif filter_mode == "exclude_street_brawl" and is_street_brawl then
should_include = false
end
if should_include and item_data["Name"] ~= nil and item_data["IsDisabled"] == false and this_cost ~= nil and this_slot ~= nil then
if slot == this_slot and this_cost >= min_souls and this_cost < max_souls then
local item_name_english = lang_module.get_string(item_key, "en") -- Get the English name
local item_link = linkOverrides[item_name_english] or item_name_english -- Use override link if available
local lang_code = lang_module.get_lang_code() -- Get the language code from the subpage
local item_name_local = lang_module.get_string(item_key, lang_code) -- Get the localized name
-- Construct the template based on the type
local item_template
if template == "ItemIcon" then
if lang_code == "en" then
-- For English pages, do not include lang or localized name
item_template = "{{ItemIcon|" .. item_name_english .. "}}"
else
-- For non-English pages, include lang and localized name
item_template = "{{ItemIcon|" .. item_name_english .. "|lang=" .. lang_code .. "|" .. item_name_local .. "}}"
end
elseif template == "ItemBox" then
if lang_code == "en" then
-- For English pages, do not include item_loc or link
-- Display cost as "Legendary" for street brawl items
if is_street_brawl == true then
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|link=" .. item_link .. "|item_price=Legendary" .. "}}"
else
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|link=" .. item_link .. "}}"
end
else
-- For non-English pages, include item_loc and link
local link_local = item_link .. "/" .. lang_code -- Add subpage for non-English languages
if is_street_brawl == true then
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link_local ..
"|item_price={{#invoke:Lang|get_string|Citadel_ItemDraft_Legendary}}" .. "}}"
else
item_template = "{{ItemBox|item_name=" .. item_name_english .. "|item_loc=" .. item_name_local .. "|link=" .. link_local .. "}}"
end
end
else
return "Invalid template type"
end
table.insert(items, item_template)
end
end
end
-- Order list alphabetically
table.sort(items) -- O(nlogn)
-- Add each item to output
-- Each item is already wrapped in the template, so no need for additional wrapping
local ret = table.concat(items, sep)
return ret
end
-- for [[Template:Item Navbox]]
-- Supports filter parameter via frame.args["filter"]
function p.get_item_nav_bulletpoints(slot, min_souls, max_souls, debug_mode, filter_mode)
-- Handle the case where it's called via #invoke (i.e., from wikitext)
if type(slot) == "table" and slot.args then
local frame = slot
slot = frame.args[1]
min_souls = frame.args[2]
max_souls = frame.args[3]
debug_mode = frame.args["debug_mode"]
filter_mode = frame.args["filter"]
end
local sep = ' • '
local item_list = write_wrapped_item_list(slot, min_souls, max_souls, "ItemIcon", sep, filter_mode)
return process_debug_mode(item_list, debug_mode)
end
-- for [[Template:Infobox ShopItems]]
-- Supports filter parameter via frame.args["filter"]
function p.get_item_nav_cards(slot, min_souls, max_souls, debug_mode, filter_mode)
-- Handle the case where it's called via #invoke (i.e., from wikitext)
if type(slot) == "table" and slot.args then
local frame = slot
slot = frame.args[1]
min_souls = frame.args[2]
max_souls = frame.args[3]
debug_mode = frame.args["debug_mode"]
filter_mode = frame.args["filter"]
end
local sep = ' '
local item_list = write_wrapped_item_list(slot, min_souls, max_souls, "ItemBox", sep, filter_mode)
return process_debug_mode(item_list, debug_mode)
end
-- for [[Template:Item Navbox]] subgroup rows
-- Writes price tiers and appends Street Brawl section if items exist
function p.write_item_slot_subgroup(frame)
local slot = frame.args[1]
local type = frame.args[2]
local debug_mode = frame.args['debug_mode']
local street_brawl_label = frame.args['street_brawl_label'] or "Street Brawl"
if slot == nil then return "'slot' parameter is required" end
-- Define base args
local template_title = "Navbox subgroup"
local template_args = {
["groupstyle"] = "background-color:" .. util_module.get_slot_color(slot) .. ";width:10%;min-width:70px;border-radius: 8px 0 0 8px",
["grouppadding"] = "5px",
["listpadding"] = "0 0.25rem",
}
local soul_style = "font-size: 12px; text-shadow: 1px 1px rgba(0, 0, 0, 0.3);"
local prices = generic_module.get_item_price_per_tier()
local group_index = 1
for i, souls in ipairs(prices) do
min_souls = souls
--Skip 0 to i1 as no items cost less than 500
if min_souls ~= 0 then
-- Determine upper bound for soul tier
max_souls = prices[i+1]
if max_souls == nil then
max_souls = min_souls * 10
end
-- Generate list for this price tier, excluding Street Brawl items
local list
if type=='get_item_nav_cards' then
list = p.get_item_nav_cards(slot, min_souls, max_souls, debug_mode, "exclude_street_brawl")
elseif type=='get_item_nav_bulletpoints' then
list = p.get_item_nav_bulletpoints(slot, min_souls, max_souls, debug_mode, "exclude_street_brawl")
else
return "'type' should be get_item_nav_cards or get_item_nav_bulletpoints"
end
-- Only add the group if there are items in this tier
if list and list ~= "" then
template_args["group" .. group_index] = frame:expandTemplate{title="Souls", args={[1] = min_souls, ["Shadow"] = soul_style}}
template_args["list" .. group_index] = list
group_index = group_index + 1
end
end
end
-- Add Street Brawl section at the bottom of the slot
local sb_min = 0
local sb_max = 999999
local sb_list
if type=='get_item_nav_cards' then
sb_list = p.get_item_nav_cards(slot, sb_min, sb_max, debug_mode, "street_brawl_only")
elseif type=='get_item_nav_bulletpoints' then
sb_list = p.get_item_nav_bulletpoints(slot, sb_min, sb_max, debug_mode, "street_brawl_only")
end
-- Only add Street Brawl group if there are items for this slot
if sb_list and sb_list ~= "" then
-- Style the link to match other tier headers with white text inside the link to prevent visited link color
local sb_style = "color:#98ffde; font-family:'Retail Demo', sans-serif; text-wrap: nowrap; text-shadow: 0px 0px 2px #2c312e, 1.3px 1.3px rgba(0, 0, 0, 0.2);"
local sb_link_text = "[[Street Brawl{{if_lang}}|<span style=\"" .. sb_style .. "\"><b>" .. street_brawl_label .. "</b></span>]]"
template_args["group" .. group_index] = frame:preprocess(sb_link_text)
template_args["list" .. group_index] = sb_list
end
return frame:expandTemplate{title=template_title, args=template_args}
end
-- for [[Template:Active Items]]
function p.generate_active_items_table(frame)
local active_items = {}
-- 1. Collect active items and their cost
for item_key, item_data in pairs(items_data) do
-- Convert cost to a number; will be nil if the JSON value is null or missing
local cost = tonumber(item_data["Cost"])
if item_data["Name"] and
item_data["IsDisabled"] == false and
cost ~= nil and cost > 0 and -- FILTER: Must have a cost greater than 0
item_data["Activation"] and
item_data["Activation"] ~= "Passive" then
table.insert(active_items, {
name = item_data["Name"],
key = item_key,
cost = cost,
slot = item_data["Slot"] or "Weapon",
has_active_desc = item_data["ActiveDescription"] ~= nil
})
end
end
-- 2. Sort by name
table.sort(active_items, function(a, b) return a.name < b.name end)
-- 3. Generate wiki markup
local wikitext = [=[
{| class="wikitable sortable" style="width:100%"
|+{{#invoke:Dictionary|translate|Active Items}}
! colspan="2" | {{#invoke:Lang|get_string|Citadel_HeroBuilds_CategoryNameLabel}}
! {{#invoke:Lang|get_string|Citadel_UserFeedback_TypeLabel}}
! {{Souls|{{#invoke:Dictionary|translate|Cost}}}}
! {{#invoke:Lang|get_string|Citadel_Mod_Tooltip_Active}}
! {{#invoke:Lang|get_string|AbilityCooldown_label}}
]=]
-- 4. Add rows for each item
for _, item in ipairs(active_items) do
-- Determine background color and item type
local bg_color, item_type
if item.slot == "Armor" then
bg_color = "#86C921"
item_type = "Armor"
elseif item.slot == "Tech" then
bg_color = "#DE9CFF"
item_type = "Tech"
else
bg_color = "#FCAC4D"
item_type = "Weapon"
end
-- The cost cell uses 'data-sort-value' to provide a clean number for the client-side sorter,
-- while the cell's visible content is formatted by the {{Souls}} template.
wikitext = wikitext .. "\n" .. string.format([=[
|-
! style="background-color:%s" | [[File:%s.png|64x64px]]
! [[%s{{If_lang}}|{{#invoke:Lang|get_string|%s}}]]
| style="text-align:center;font-weight:bold" | {{ItemType|%s|{{#invoke:Lang|get_string|CitadelCategory%s}}}}
| data-sort-value="%d" style="text-align:center;font-size:15px" | {{Souls|%d}}
| {{#invoke:Utilities|process_variables|%s_active_desc|%s}}{{#invoke:Utilities|process_variables|%s_desc|%s}}{{#invoke:Utilities|process_variables|%s_active|%s}}
| style="text-align:center;font-size:16px" | {{#invoke:ItemData|get_prop|%s|AbilityCooldown}}s
]=],
bg_color,
item.name,
item.name, item.key,
item_type, item_type,
item.cost, item.cost,
item.key, item.name, item.key, item.name, item.key, item.name,
item.name)
end
wikitext = wikitext .. "\n|}"
return frame:preprocess(wikitext)
end
return p