Module:Sandbox/Aurelain/ArtifactsOverview
From Heroes of Might and Magic: Olden Era Official Wiki
This module renders a giant table with all artifacts. Scroll artifacts are consolidated into 3 generic scroll artifacts (normal, enchanted and mythic). Campaign artifacts are excluded.
A hyper parameter is supported. For more information, see Module:UtilHyper/doc.
Usage
Input: {{#invoke:Sandbox/Aurelain/ArtifactsOverview|display | lang=en | hyper=Attack=Hero_Basics#Attributes}}
Output:
| id | nameX | ||
|---|---|---|---|
| ambassadors_word_ambassadors_sash_artifact | Ambassador's Sash | Ambassador's Sash | |
| ambassadors_word_diplomatic_gifts_artifact | Diplomatic Gifts | Diplomatic Gifts | |
| ancient_idol_artifact | Ancient Idol | Ancient Idol | |
| angelic_alliance_armor_of_wonder_artifact | Armor of Wonder | Armor of Wonder | |
| angelic_alliance_celestial_sash_of_bliss_artifact | Celestial Sash of Bliss | Celestial Sash of Bliss | |
| angelic_alliance_helm_of_heavenly_enlightenment_artifact | Helm of Heavenly Enlightenment | Helm of Heavenly Enlightenment | |
| angelic_alliance_lions_shield_of_courage_artifact | Lion's Shield of Courage | Lion's Shield of Courage | |
| angelic_alliance_sandals_of_the_saint_artifact | Sandals of the Saint | Sandals of the Saint | |
| angelic_alliance_sword_of_judgement_artifact | Sword of Judgement | Sword of Judgement | |
| banner_of_four_winds_artifact | Banner of Six Winds | Banner of Six Winds | |
| beelzebubs_blessing_chitinous_shield_artifact | Chitinous Shield | Chitinous Shield | |
| beelzebubs_blessing_demon_claw_artifact | Demon Claw | Demon Claw | |
| beelzebubs_blessing_demon_crest_artifact | Beelzebub's Boon | Beelzebub's Boon | |
| beelzebubs_blessing_heartbeat_artifact | Heartbeat | Heartbeat | |
| boreolos_foot_artifact | Boreoloth's Tail | Boreoloth's Tail | |
| boreolos_hand_artifact | Boreoloth's Hand | Boreoloth's Hand | |
| boreolos_head_artifact | Boreoloth's Head | Boreoloth's Head | |
| boreolos_heart_artifact | Boreoloth's Heart | Boreoloth's Heart | |
| caduceus_artifact | Caduceus | Caduceus | |
| campaign_M3_captured_priestesses_item | Chained Priestesses | Chained Priestesses | |
| campaign_M3_freed_priestesses_item | Injured Priestesses | Injured Priestesses | |
| campaign_M9_phoenix_egg_item | Phoenix Egg | Phoenix Egg | |
| campaign_ichor_item | Blob of Red | Blob of Red | |
| cards_deck_artifact | Deck of Spells | Deck of Spells | |
| chain_link_artifact | Chain Link | Chain Link | |
| chain_mail_artifact | Chain Mail | Chain Mail | |
| clothes_of_enlightenment_artifact | Robe of Enlightenment | Robe of Enlightenment | |
| crown_of_the_supreme_magi_artifact | Crown of the Supreme Magi | Crown of the Supreme Magi | |
| demonic_heart_artifact | Demonic Heart | Demonic Heart | |
| duelists_pride_brass_knuckles_artifact | Brass Knuckles | Brass Knuckles | |
| duelists_pride_buckler_artifact | Buckler | Buckler | |
| duelists_pride_rapier_artifact | Rapier | Rapier | |
| eagle_armor_artifact | Eagle Armor | Eagle Armor | |
| elixir_of_life_flask_of_oblivion_artifact | Flask of Oblivion | Flask of Oblivion | |
| elixir_of_life_lifeblood_fairy_artifact | Lifeblood Fae | Lifeblood Fae | |
| elixir_of_life_ring_of_life_artifact | Ring of Life | Ring of Life | |
| enchanted_magic_scroll_artifact_day_3_magic_haste | Enchanted Magic Scroll | Enchanted Magic Scroll | |
| endless_bag_artifact | Endless Bag | Endless Bag | |
| ethereal_knowledge_glass_dagger_artifact | Crescent Dagger | Crescent Dagger | |
| ethereal_knowledge_mirror_shoes_artifact | Magic Slippers | Magic Slippers | |
| ethereal_knowledge_third_eye_artifact | Seven Eyes | Seven Eyes | |
| ethereal_knowledge_vortex_dress_artifact | Vortex Robe | Vortex Robe | |
| excalibur_artifact | Excalibur | Excalibur | |
| fallen_angel_wings_artifact | Fallen Angel Wings | Fallen Angel Wings | |
| fine_wand_artifact | Fine Wand | Fine Wand | |
| flag_of_truce_artifact | Flag of Truce | Flag of Truce | |
| garotte_artifact | Garotte | Garotte | |
| gifts_of_dwarven_lords_crimson_resonance_controller_artifact | Crimson Resonance Controller | Crimson Resonance Controller | |
| gifts_of_dwarven_lords_emerald_resonance_controller_artifact | Emerald Resonance Controller | Emerald Resonance Controller | |
| gifts_of_dwarven_lords_protective_belt_artifact | Protective Belt | Protective Belt | |
| golden_goose_egg_artifact | Golden Goose Egg | Golden Goose Egg | |
| head_torch_artifact | Head Torch | Head Torch | |
| holy_sigil_of_eridore_artifact | Holy Sigil of Eridore | Holy Sigil of Eridore | |
| holy_sigil_of_insara_artifact | Holy Sigil of Insara | Holy Sigil of Insara | |
| holy_sigil_of_mearea_artifact | Holy Sigil of Mearea | Holy Sigil of Mearea | |
| holy_sigil_of_quix_artifact | Holy Sigil of Quix | Holy Sigil of Quix | |
| holy_sigil_of_roph_artifact | Holy Sigil of Roph | Holy Sigil of Roph | |
| holy_sigil_of_the_second_man_artifact | Holy Sigil of The Second Man | Holy Sigil of The Second Man | |
| holy_sigil_of_the_seven_magi_artifact | Holy Sigil of The Seven Magi | Holy Sigil of The Seven Magi | |
| holy_sigil_of_uurdt_artifact | Holy Sigil of Uurdt | Holy Sigil of Uurdt | |
| hourglass_of_protection_artifact | Pelagic Hourglass | Pelagic Hourglass | |
| inner_song_fancy_mask_artifact | Fancy Mask | Fancy Mask | |
| inner_song_music_sheet_artifact | Music Sheet | Music Sheet | |
| inner_song_singing_pan_pipe_artifact | Singing Pan-Pipe | Singing Pan-Pipe | |
| keepers_fortitude_keepers_oberegus_artifact | Keeper's Amulet | Keeper's Amulet | |
| keepers_fortitude_keepers_ring_artifact | Keeper's Ring | Keeper's Ring | |
| knights_honor_armet_artifact | Armet | Armet | |
| knights_honor_drums_of_war_artifact | Drum of War | Drum of War | |
| knights_honor_lance_artifact | Lance | Lance | |
| knights_honor_misericorde_artifact | Misericorde | Misericorde | |
| knights_honor_plate_armor_artifact | Plate Armor | Plate Armor | |
| legions_step_artifact | Legion's Leg | Legion's Leg | |
| living_arrows_light_and_shade_cloak_artifact | Light-and-Shade Cloak | Light-and-Shade Cloak | |
| living_arrows_quivering_quiver_artifact | Quivering Quiver | Quivering Quiver | |
| living_arrows_shroomwood_bow_artifact | Shroomwood Bow | Shroomwood Bow | |
| lords_ring_artifact | Lord's Ring | Lord's Ring | |
| magic_key_ring_artifact | Magic Key Ring | Magic Key Ring | |
| magic_scroll_artifact_day_3_magic_haste | Magic Scroll | Magic Scroll | |
| milos_curse_golden_moth_artifact | Golden Moth | Golden Moth | |
| milos_curse_golden_pig_artifact | Golden Pig | Golden Pig | |
| milos_curse_skull_of_milos_artifact | Skull of Milos | Skull of Milos | |
| monster_head_artifact | Monster Head | Monster Head | |
| ogres_club_of_havoc_artifact | Ogre's Club of Havoc | Ogre's Club of Havoc | |
| omencaller_artifact | Omencaller | Omencaller | |
| orb_of_destruction_artifact | Orb of Destruction | Orb of Destruction | |
| orb_of_inhibition_artifact | Orb of Inhibition | Orb of Inhibition | |
| paupers_glory_dumb_club_artifact | Fish-to-the-Face | Fish-to-the-Face | |
| paupers_glory_last_coin_artifact | Last Coin | Last Coin | |
| paupers_glory_rags_artifact | Rags | Rags | |
| paupers_glory_rope_belt_artifact | Rope Belt | Rope Belt | |
| paupers_glory_straw_hat_artifact | Straw Hat | Straw Hat | |
| paupers_glory_wooden_ring_artifact | Wooden Ring | Wooden Ring | |
| pole_star_artifact | Pole Star | Pole Star | |
| power_of_the_dragon_father_dragon_crest_artifact | Crown of Dragontooth | Crown of Dragontooth | |
| power_of_the_dragon_father_dragon_scale_armor_artifact | Dragon Scale Armor | Dragon Scale Armor | |
| power_of_the_dragon_father_dragon_scale_shield_artifact | Dragon Scale Shield | Dragon Scale Shield | |
| power_of_the_dragon_father_dragon_wing_artifact | Dragon Wing Tabard | Dragon Wing Tabard | |
| power_of_the_dragon_father_dragonbone_greaves_artifact | Dragonbone Greaves | Dragonbone Greaves | |
| power_of_the_dragon_father_piercing_eye_of_a_dragon_artifact | Quiet Eye of a Dragon | Quiet Eye of a Dragon | |
| power_of_the_dragon_father_red_dragon_flame_tongue_artifact | Red Dragon Flame Tongue | Red Dragon Flame Tongue | |
| power_of_the_dragon_father_slithering_sash_artifact | Slithering Sash | Slithering Sash | |
| resonant_sphere_orb_of_daylight_artifact | Orb of Dawn | Orb of Dawn | |
| resonant_sphere_orb_of_eternity_artifact | Orb of Eternity | Orb of Eternity | |
| resonant_sphere_orb_of_twilight_artifact | Orb of Twilight | Orb of Twilight | |
| resonant_sphere_primal_orb_artifact | Primordial Orb | Primordial Orb | |
| ring_of_neutrality_artifact | Ring of Neutrality | Ring of Neutrality | |
| rule_of_shadow_liquid_silence_artifact | Liquid Silence | Liquid Silence | |
| rule_of_shadow_nostrias_gaze_artifact | Amelchia's Law | Amelchia's Law | |
| rule_of_shadow_the_truthmaker_artifact | Truthmaker | Truthmaker | |
| rule_of_shadow_the_truthseeker_artifact | Truthseeker | Truthseeker | |
| runestone_shards_artifact | Runestone Shards | Runestone Shards | |
| scholars_wisdom_scholars_oberegus_artifact | Scholar's Amulet | Scholar's Amulet | |
| scholars_wisdom_scholars_tiara_artifact | Scholar's Tiara | Scholar's Tiara | |
| seal_of_silence_artifact | Seal of Silence | Seal of Silence | |
| seven_league_boots_artifact | Seven-League Boots | Seven-League Boots | |
| shackles_of_war_artifact | Shackles of War | Shackles of War | |
| shadow_of_death_bone_boots_artifact | Bone Boots | Bone Boots | |
| shadow_of_death_cursed_armor_artifact | Ribcage Armor | Ribcage Armor | |
| shadow_of_death_dark_hatchet_artifact | Dark Hatchet | Dark Hatchet | |
| shadow_of_death_second_shade_artifact | Second Shade | Second Shade | |
| shamaniac_soul_clutching_ring_artifact | Clenching Ring | Clenching Ring | |
| shamaniac_soul_gemwood_mask_artifact | Sirin Mask | Sirin Mask | |
| shamaniac_soul_iridescent_cloak_artifact | Iridescent Cloak | Iridescent Cloak | |
| shamaniac_soul_shaman_staff_artifact | Shaman Staff | Shaman Staff | |
| shoddy_shield_artifact | Shoddy Shield | Shoddy Shield | |
| sixth_finger_artifact | Sixth Finger | Sixth Finger | |
| soulless_sash_artifact | Soulless Sash | Soulless Sash | |
| soulscaller_ring_artifact | Soulcaller Ring | Soulcaller Ring | |
| spellbinders_hat_artifact | Spellbinder's Hat | Spellbinder's Hat | |
| spells_in_a_bottle_artifact | Spells in Bottles | Spells in Bottles | |
| spyglass_artifact | Spyglass | Spyglass | |
| swamp_boots_artifact | Swamp Boots | Swamp Boots | |
| tactical_guide_artifact | Tactical Guide | Tactical Guide | |
| tarq_of_the_rampaging_ogre_artifact | Shield of the Rampaging Ogre | Shield of the Rampaging Ogre | |
| tranquility_brightmind_tiara_artifact | Mirror Tiara | Mirror Tiara | |
| tranquility_ring_of_serenity_artifact | Shard of Serenity | Shard of Serenity | |
| tunic_of_the_cyclops_king_artifact | Tunic of the Cyclops King | Tunic of the Cyclops King | |
| two_faced_mask_artifact | Two-faced Mask | Two-faced Mask | |
| ukhtabar_seal_tabar_seal_artifact | Tabar Signet-Ring | Tabar Signet-Ring | |
| ukhtabar_seal_ukh_seal_artifact | Ukh Signet | Ukh Signet | |
| voodoosh_doll_artifact | Voodoo Doll | Voodoo Doll | |
| wanderers_way_backpack_artifact | Backpack | Backpack | |
| wanderers_way_boots_of_travel_artifact | Boots of Travel | Boots of Travel | |
| warlord_boots_artifact | Warlord Boots | Warlord Boots | |
| warriors_strength_warriors_belt_artifact | Warrior's Belt | Warrior's Belt | |
| warriors_strength_warriors_oberegus_artifact | Warrior's Amulet | Warrior's Amulet | |
| wizards_might_wizards_cloak_artifact | Wizard's Cloak | Wizard's Cloak | |
| wizards_might_wizards_oberegus_artifact | Wizard's Amulet | Wizard's Amulet | |
-- Usage: {{#invoke:ArtifactsOverview|display | lang=en}}
local p = {}
local f = mw.ustring.format
-- Note: The right side is just a fallback, it will seldom be used.
local TRANSLATION_IDS = {
wiki_none = 'None'
}
-- Displays a variable
------------------------------------------------------------------------------------------------------------------------
local function dump(target)
return '<pre>' .. mw.dumpObject(target) .. '</pre>'
end
-- Spawns a safe robotic url from an English name, fit for adding it before the visible name
------------------------------------------------------------------------------------------------------------------------
local function getUrl(nameEn, lang)
if not nameEn then
return ''
end
local url = nameEn
if lang ~= 'en' then
url = url .. '/' .. lang
end
return url
end
-- Retrieves the text for some specific ids from Cargo Translations.
------------------------------------------------------------------------------------------------------------------------
local function translateIds(ids, lang, extra)
-- Key list
local list = {}
for key, _ in pairs(ids) do
list[#list + 1] = key
end
local idListString = '"' .. table.concat(list, '", "') .. '"'
-- Cargo
local where = {}
table.insert(where, 'target_id IN (' .. idListString .. ')')
table.insert(where, 'language = "' .. lang .. '"')
if extra then
table.insert(where, extra)
end
local results = mw.ext.cargo.query('Translation', 'target_id, name', {
where = table.concat(where, ' AND '),
limit = 100
})
-- Dictionary
local dictionary = mw.clone(ids)
for key, value in pairs(dictionary) do
--dictionary[key] = value .. '[[Data:WikiTranslations/' .. lang .. '#' .. key .. '|💬]]'
dictionary[key] = value .. '🗯️'
end
for _, row in ipairs(results) do
local name = row['name']
if name and name ~= '' then
dictionary[row['target_id']] = name
end
end
return dictionary
end
-- Converts a dictionary into a linear array
------------------------------------------------------------------------------------------------------------------------
local function flatten(hub)
local list = {}
for _, entry in pairs(hub) do
list[#list + 1] = entry
end
return list
end
-- Interrogates the main Cargo table
------------------------------------------------------------------------------------------------------------------------
local function queryMain(lang)
-- fields:
local fields = {}
table.insert(fields, 'A.id = id');
table.insert(fields, 'T.name = name');
table.insert(fields, 'T.language = language');
-- where:
local where = {}
table.insert(where, '(A.id NOT LIKE "%_magic_%" OR A.id LIKE "%_magic_haste")')
table.insert(where, 'T.type = "artifact"')
table.insert(where, '(T.language = "en" OR T.language = "' .. lang .. '")')
-- query:
return mw.ext.cargo.query('Artifact=A, Translation=T', table.concat(fields, ','), {
join = 'A.id = T.target_id',
where = table.concat(where, ' AND '),
limit = 500
})
end
-- Folds all Cargo results into a single dictionary:
------------------------------------------------------------------------------------------------------------------------
local function consolidate(lang, results)
local hub = {}
for _, row in ipairs(results) do
local id = row.id
local entry = hub[id]
if not entry then
entry = {}
entry.id = id or ''
hub[id] = entry
end
if row.language == lang then
entry.name = row.name or ''
end
if row.language == 'en' then
entry.nameEn = row.name or ''
end
end
return hub
end
------------------------------------------------------------------------------------------------------------------------
local function sortList(a, b)
return a.id < b.id
end
-- Boilerplate for the header cells
------------------------------------------------------------------------------------------------------------------------
local function addTh(tr, text)
return tr:tag('th'):wikitext(text)
end
-- Boilerplate for the body cells
------------------------------------------------------------------------------------------------------------------------
local function addTd(tr, content)
if type(content) == "string" then
return tr:tag('td'):wikitext(content)
else
return tr:tag('td'):node(content)
end
end
-- Boilerplate for the separator rows
------------------------------------------------------------------------------------------------------------------------
local function addSeparator(htmlTable, className, content)
htmlTable:tag('tr')
:addClass('separator')
:addClass(className)
:tag('td'):attr('data-sort-value', ''):attr('colspan', 100):wikitext(content):done()
end
------------------------------------------------------------------------------------------------------------------------
local function createHeader(htmlTable)
local tr = htmlTable:tag('tr')
addTh(tr, 'id'):attr('colspan', 2)
addTh(tr, 'nameX'):attr('colspan', 2)
end
------------------------------------------------------------------------------------------------------------------------
local function createBody(htmlTable, list)
local currentType = list[1].param1
local currentFaction = list[1].faction
for _, item in ipairs(list) do
-- separators
if item.faction ~= currentFaction then
currentFaction = item.faction
currentType = item.class_type
addSeparator(htmlTable, 'separator-large', '')
elseif item.class_type ~= currentType then
currentType = item.class_type
addSeparator(htmlTable, 'separator-tiny', '')
end
local tr = htmlTable:tag('tr'):addClass('artifact')
addTd(tr, item.id)
addTd(tr, item.nameEn)
addTd(tr, item.name)
end
end
-- M A I N
------------------------------------------------------------------------------------------------------------------------
function p.display(frame)
--do return dump(frame) end
-- Args
local args = frame.args
local lang = args.lang ~= '' and args.lang or 'en'
--lang = 'ja'
-- Language
local words = translateIds(TRANSLATION_IDS, lang)
-- Cargo
local results = queryMain(lang)
local hub = consolidate(lang, results)
local list = flatten(hub);
if #list == 0 then return words.wiki_none end
-- Various manipulations
table.sort(list, sortList)
-- Table
local htmlTable = mw.html.create('table')
htmlTable:addClass('wikitable sortable')
createHeader(htmlTable)
createBody(htmlTable, list)
-- Output
local styleTag = frame:extensionTag('templatestyles', '', { src = frame:getTitle() .. '/styles.css' })
return '<div class="artifacts-overview">' .. styleTag .. tostring(htmlTable) .. '</div>'
end
return p


