Editing
Module
:
Sandbox/Monster Domosed
Give feedback
Jump to navigation
Jump to search
Warning:
You are not logged in. Once you make an edit, a temporary account will be created for you.
Learn more
.
Log in
or
create an account
to continue receiving notifications after this account expires, and to access other features.
Anti-spam check. Do
not
fill this in!
local p = {} local data = mw.loadJsonData("Data:ItemData.json") local ability_data = mw.loadJsonData("Data:AbilityCards.json") -------------------------------------------------- -- Constants -------------------------------------------------- -- Desired type order local TYPE_ORDER = { Weapon = 1, Armor = 2, -- Vitality Tech = 3 -- Spirit } -------------------------------------------------- -- Helpers -------------------------------------------------- local function is_enabled(item) return item and item["Name"] ~= nil and (item["IsDisabled"] == false or item["IsDisabled"] == nil) end -- Returns numeric cost or nil if invalid local function get_cost(item) local cost = tonumber(item["Cost"]) if cost == nil then return nil end return cost end local function get_type_rank(item) return TYPE_ORDER[item["Slot"]] or math.huge end -------------------------------------------------- -- Core logic -------------------------------------------------- local function get_sorted_items() local items = {} for _, item in pairs(data) do -- Exclude items with null / missing / non-numeric cost local cost = get_cost(item) if is_enabled(item) and cost ~= nil then table.insert(items, item) end end table.sort(items, function(a, b) -- 1. Sort by type local type_a = get_type_rank(a) local type_b = get_type_rank(b) if type_a ~= type_b then return type_a < type_b end -- 2. Sort by cost (low β high) local cost_a = get_cost(a) local cost_b = get_cost(b) if cost_a ~= cost_b then return cost_a < cost_b end -- 3. Stable fallback: name return a["Name"] < b["Name"] end) return items end -------------------------------------------------- -- Public (module-level) access -------------------------------------------------- function p._get_enabled_items_sorted() return get_sorted_items() end function p._get_enabled_item_names_sorted() local items = get_sorted_items() local names = {} for _, item in ipairs(items) do table.insert(names, item["Name"]) end return names end -------------------------------------------------- -- Abilities -------------------------------------------------- local function get_all_abilities() local abilities = {} for _, hero in pairs(ability_data) do if type(hero) == "table" then for key, ability in pairs(hero) do if tonumber(key) ~= nil and type(ability) == "table" and ability["Name"] ~= nil then table.insert(abilities, { Index = tonumber(key), Name = ability["Name"] }) end end end end return abilities end local function get_formatted_abilities(frame) local abilities = get_all_abilities() local output = {} for _, ability in ipairs(abilities) do table.insert(output, frame:expandTemplate{ title = "AbilityIcon", args = { ability["Name"] } }) end return output end -------------------------------------------------- -- Invoke access points -------------------------------------------------- -- {{#invoke:Sandbox/Monster Domosed|get_list}} function p.get_list(frame) return table.concat(p._get_enabled_item_names_sorted(), "\n") end -- {{#invoke:Sandbox/Monster Domosed|get_csv}} function p.get_csv(frame) return table.concat(p._get_enabled_item_names_sorted(), ",") end -- {{#invoke:Sandbox/Monster Domosed|get_count}} function p.get_count(frame) return tostring(#p._get_enabled_item_names_sorted()) end -- {{#invoke:Sandbox/Monster Domosed|get_abilities}} function p.get_abilities(frame) return table.concat(get_formatted_abilities(frame), "\n") end -- {{#invoke:Sandbox/Monster Domosed|get_abilities_csv}} function p.get_abilities_csv(frame) return table.concat(get_formatted_abilities(frame), ",") end -- {{#invoke:Sandbox/Monster Domosed|get_ability_count}} function p.get_ability_count(frame) return tostring(#get_all_abilities()) end return p
Summary:
Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Page included on this page:
Module:Sandbox/Monster Domosed/doc
(
view source
)
Navigation menu
Personal tools
Create account
Log in
associated-pages
Module
Discussion
English
Views
Read
Edit source
History
Tools
Search
Discord
Discord
Navigation
Main page
About us
Random page
Special pages
Recent changes
Wraith
3h ago
Β·
~2026-LaneFireUrn1085
Unstable Rift
12h ago
Β·
~2026-IvyGankStone1157
Haze/Sounds
13h ago
Β·
Gammaton32
Haze/Voice lines
13h ago
Β·
Gammaton32
Show more...
Interface Admin
Common CSS
Vector CSS
Minerva CSS
Citizen CSS
Brown theme CSS
Gadgets
Gadgets definition
Editing
How to edit
Style guide
All guides
New files
Unresolved feedback
Tools
What links here
Related changes
Page information