Module:Sandbox/Aurelain/ArtifactsOverview: Difference between revisions
From Heroes of Might and Magic: Olden Era Official Wiki
No edit summary |
No edit summary |
||
| Line 81: | Line 81: | ||
local fields = {} | local fields = {} | ||
table.insert(fields, 'A.id = id'); | table.insert(fields, 'A.id = id'); | ||
table.insert(fields, 'A.slot = slot'); | --table.insert(fields, 'A.slot = slot'); | ||
table.insert(fields, 'A.rarity = rarity'); | --table.insert(fields, 'A.rarity = rarity'); | ||
table.insert(fields, 'A.artifact_set_id = artifact_set_id'); | --table.insert(fields, 'A.artifact_set_id = artifact_set_id'); | ||
--table.insert(fields, 'A.goods_value = goods_value'); | --table.insert(fields, 'A.goods_value = goods_value'); | ||
table.insert(fields, 'A.max_level = max_level'); | --table.insert(fields, 'A.max_level = max_level'); | ||
table.insert(fields, 'A.cost_base = cost_base'); | --table.insert(fields, 'A.cost_base = cost_base'); | ||
table.insert(fields, 'A.cost_per_level = cost_per_level'); | --table.insert(fields, 'A.cost_per_level = cost_per_level'); | ||
table.insert(fields, 'T.language = language'); | table.insert(fields, 'T.language = language'); | ||
table.insert(fields, 'T.name = name'); | table.insert(fields, 'T.name = name'); | ||
| Line 96: | Line 96: | ||
local where = {} | local where = {} | ||
table.insert(where, 'A.id NOT LIKE "campaign_%"') | table.insert(where, 'A.id NOT LIKE "campaign_%"') | ||
table.insert(where, 'T.type = "artifact"') | |||
table.insert(where, '(T.language = "en" OR T.language = "' .. lang .. '")') | table.insert(where, '(T.language = "en" OR T.language = "' .. lang .. '")') | ||
Revision as of 11:01, 29 June 2026
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:
| Artifact🗯️ | Description | upgrade | slot | rarity | artifact_set_id | max_level | cost_base | cost_per_level | ||
|---|---|---|---|---|---|---|---|---|---|---|
| Ambassador's Sash | +10% to Persuasion Power in Diplomacy. | 0 | 0 | 0 | ||||||
| Diplomatic Gifts | +10% to Persuasion Power in Diplomacy. | 0 | 0 | 0 | ||||||
| Ancient Idol | The hero ignores the restriction on using the same Magic School twice. | 0 | 0 | 0 | ||||||
| Armor of Wonder | +2 Attack, Defense, Spell Power, and Knowledge. | 0 | 0 | 0 | ||||||
| Celestial Sash of Bliss | +2 Attack, Defense, Spell Power, and Knowledge. | 0 | 0 | 0 | ||||||
| Helm of Heavenly Enlightenment | +2 Attack, Defense, Spell Power, and Knowledge. | 0 | 0 | 0 | ||||||
| Lion's Shield of Courage | +2 Attack, Defense, Spell Power, and Knowledge. | 0 | 0 | 0 | ||||||
| Sandals of the Saint | +2 Attack, Defense, Spell Power, and Knowledge. | 0 | 0 | 0 | ||||||
| Sword of Judgement | +2 Attack, Defense, Spell Power, and Knowledge. | 0 | 0 | 0 | ||||||
| Banner of Six Winds | +1 Speed to friendly creatures. | 0 | 0 | 0 | ||||||
| Chitinous Shield | +12 Defense, but –4 Attack. | 0 | 0 | 0 | ||||||
| Demon Claw | +12 Attack, but –4 Defense. | 0 | 0 | 0 | ||||||
| Beelzebub's Boon | +12 Knowledge, but –4 Spell Power. | 0 | 0 | 0 | ||||||
| Heartbeat | +12 Spell Power, but –4 Knowledge. | 0 | 0 | 0 | ||||||
| Boreoloth's Tail | +1 Defense. | 0 | 0 | 0 | ||||||
| Boreoloth's Hand | +1 Attack. | 0 | 0 | 0 | ||||||
| Boreoloth's Head | +1 Knowledge. | 0 | 0 | 0 | ||||||
| Boreoloth's Heart | +1 Spell Power. | 0 | 0 | 0 | ||||||
| Caduceus | Heroic Strike restores 4 mana. | 0 | 0 | 0 | ||||||
| Deck of Spells | Makes all tier-1 spells available to the hero. | 0 | 0 | 0 | ||||||
| Daylight Tome | Allows the hero to cast all Daylight spells. | 0 | 0 | 0 | ||||||
| Nightshade Tome | Allows the hero to cast all Nightshade spells. | 0 | 0 | 0 | ||||||
| Primal Tome | Allows the hero to cast all Primal spells. | 0 | 0 | 0 | ||||||
| Arcane Tome | Allows the hero to cast all Arcane spells. | 0 | 0 | 0 | ||||||
| Chain Link | Forbids the wearer and the enemy hero to cast tier-1 and 2 spells in combat. | 0 | 0 | 0 | ||||||
| Chain Mail | +3 Defense. | 0 | 0 | 0 | ||||||
| Robe of Enlightenment | Makes all tier-3 spells available to the hero. | 0 | 0 | 0 | ||||||
| Crown of the Supreme Magi | +4 Knowledge. | 0 | 0 | 0 | ||||||
| Demonic Heart | Replaces all the hero’s spells with their Masterful versions (if they exist). | 0 | 0 | 0 | ||||||
| Brass Knuckles | Friendly creatures take –30% counterattack Damage. | 0 | 0 | 0 | ||||||
| Buckler | Friendly creatures can counterattack even if the attacking enemy has “Swift Strike.” | 0 | 0 | 0 | ||||||
| Rapier | Friendly creatures deal +10% Melee Damage | 0 | 0 | 0 | ||||||
| Eagle Armor | +2 Morale and Luck. | 0 | 0 | 0 | ||||||
| Flask of Oblivion | All negative effects on friendly creatures last for –1 round(s). | 0 | 0 | 0 | ||||||
| Lifeblood Fae | Friendly creatures have +2 HP. | 0 | 0 | 0 | ||||||
| Ring of Life | All positive effects on friendly creatures last for +1 round(s). | 0 | 0 | 0 | ||||||
| Enchanted Magic Scroll | 0 | 0 | 0 | |||||||
| Endless Bag | Produces +1 Gem, Crystal, or Mercury daily. (The resource depends on the bearer’s faction.) | 0 | 0 | 0 | ||||||
| Crescent Dagger | Spells and creature abilities ignore 40% of enemy magic resistance. | 0 | 0 | 0 | ||||||
| Magic Slippers | Spells cost 2 less mana. | 0 | 0 | 0 | ||||||
| Seven Eyes | +1 level(s) to all spells while worn. | 0 | 0 | 0 | ||||||
| Vortex Robe | Whenever the opponent casts a spell, restores 40% of its cost as mana to the wearer. | 0 | 0 | 0 | ||||||
| Excalibur | Heroic Strike kills +1 unit(s). Works on creatures up to tier 7. | 0 | 0 | 0 | ||||||
| Fallen Angel Wings | Grants constant flight. | 0 | 0 | 0 | ||||||
| Fine Wand | +1 level to all spells. | 0 | 0 | 0 | ||||||
| Flag of Truce | The wearer keeps their army whenever they flee from battle. | 0 | 0 | 0 | ||||||
| Garotte | –1 Speed to all enemies. | 0 | 0 | 0 | ||||||
| Automated Antimagic Shield | –10% Magic Damage taken. Friendly creatures are immune to the effects of “Berserk.” | 0 | 0 | 0 | ||||||
| Crimson Resonance Controller | –20% to enemy hero Spell Power. Friendly creatures are immune to effects that prevent them from attacking. | 0 | 0 | 0 | ||||||
| Emerald Resonance Controller | –10% to enemy hero Spell Power. Friendly creatures are immune to the effects that kill additional units. | 0 | 0 | 0 | ||||||
| Protective Belt | –10% Magic Damage taken. Friendly creatures are immune to the effects of “Sleep.” | 0 | 0 | 0 | ||||||
| Golden Goose Egg | Grants a random wondrous reward after a random number of upgrades. | 0 | 0 | 0 | ||||||
| Head Torch | +1 sight radius. | 0 | 0 | 0 | ||||||
| Holy Sigil of Eridore | While worn, grants all unlearned Subskills of the following Skills: Logistics, Battle Magic, Wisdom. | 0 | 0 | 0 | ||||||
| Holy Sigil of Insara | While worn, grants all unlearned Subskills of the following Skills: Leadership, Insight, Diplomacy, Tactics. | 0 | 0 | 0 | ||||||
| Holy Sigil of Mearea | While worn, grants all unlearned Subskills of the following Skills: Luck, Economy, Daylight Magic. | 0 | 0 | 0 | ||||||
| Holy Sigil of Quix | While worn, grants all unlearned Subskills of the following Skills: Arcane Magic, Scouting, Battlecraft, Thaumaturgy. | 0 | 0 | 0 | ||||||
| Holy Sigil of Roph | While worn, grants all unlearned Subskills of the following Skills: Righteousness, Necromancy, Murmuring, Triumvirate’s Strength, Abyssal Communion, Summon Swarm. | 0 | 0 | 0 | ||||||
| Holy Sigil of The Second Man | While worn, grants all unlearned Subskills of the following Skills: Offense, Summon Avatar, Siegecraft, Combat. | 0 | 0 | 0 | ||||||
| Holy Sigil of The Seven Magi | While worn, grants all unlearned Subskills of the following Skills: Sorcery, Nightshade Magic, Resistance. | 0 | 0 | 0 | ||||||
| Holy Sigil of Uurdt | While worn, grants all unlearned Subskills of the following Skills: Defense, Primal Magic, Recruitment. | 0 | 0 | 0 | ||||||
| Pelagic Hourglass | The cooldowns of all spells are reduced by 1 round(s). | 0 | 0 | 0 | ||||||
| Fancy Mask | Generates 2 Focus Point(s) at the start of the battle. | 0 | 0 | 0 | ||||||
| Music Sheet | Friendly creatures’ abilities deal +40% Damage. | 0 | 0 | 0 | ||||||
| Singing Pan-Pipe | All effects applied by friendly creatures last +1 round(s). | 0 | 0 | 0 | ||||||
| Keeper's Amulet | +2 Defense. | 0 | 0 | 0 | ||||||
| Keeper's Ring | +2 Defense. | 0 | 0 | 0 | ||||||
| Armet | +2 Defense. | 0 | 0 | 0 | ||||||
| Drum of War | Friendly creatures deal +1 Damage. | 0 | 0 | 0 | ||||||
| Lance | +3 Attack. | 0 | 0 | 0 | ||||||
| Misericorde | +2 Attack. | 0 | 0 | 0 | ||||||
| Plate Armor | +3 Defense. | 0 | 0 | 0 | ||||||
| Legion's Leg | +50% to all creature growth in all your cities. | 0 | 0 | 0 | ||||||
| Light-and-Shade Cloak | Friendly creatures can still use Ranged attacks while adjacent to enemy creatures. | 0 | 0 | 0 | ||||||
| Quivering Quiver | Friendly creatures deal +10% Ranged Damage. | 0 | 0 | 0 | ||||||
| Shroomwood Bow | Eliminates Ranged Damage penalty for friendly creatures. | 0 | 0 | 0 | ||||||
| Lord's Ring | Friendly creatures have +1 Initiative. | 0 | 0 | 0 | ||||||
| Magic Key Ring | Negates all effects that restrict creature rearrangement, surrendering, fleeing, and using the Spellbook and hero abilities in battle. | 0 | 0 | 0 | ||||||
| Magic Scroll | 0 | 0 | 0 | |||||||
| Golden Moth | +250 Gold daily. | 0 | 0 | 0 | ||||||
| Golden Pig | +500 Gold daily. | 0 | 0 | 0 | ||||||
| Skull of Milos | +1000 Gold daily. | 0 | 0 | 0 | ||||||
| Monster Head | All creatures always have neutral Morale in battle. | 0 | 0 | 0 | ||||||
| Mythic Magic Scroll | 0 | 0 | 0 | |||||||
| Ogre's Club of Havoc | +4 Attack. | 0 | 0 | 0 | ||||||
| Omencaller | –1 to enemy Luck. | 0 | 0 | 0 | ||||||
| Orb of Destruction | Heroic Strike deals +10 base Damage. | 0 | 0 | 0 | ||||||
| Orb of Inhibition | On the first round of the battle, heroes cannot use their Spellbook or active abilities. | 0 | 0 | 0 | ||||||
| Fish-to-the-Face | +1 Attack. | 0 | 0 | 0 | ||||||
| Last Coin | +1 Luck. | 0 | 0 | 0 | ||||||
| Rags | +1 Spell Power. | 0 | 0 | 0 | ||||||
| Rope Belt | +1 Defense. | 0 | 0 | 0 | ||||||
| Straw Hat | +1 Knowledge. | 0 | 0 | 0 | ||||||
| Wooden Ring | +1 Morale. | 0 | 0 | 0 | ||||||
| Pole Star | Global Map spells of the hero cost 0 mana. | 0 | 0 | 0 | ||||||
| Crown of Dragontooth | +4 Spell Power and Knowledge. | 0 | 0 | 0 | ||||||
| Dragon Scale Armor | +4 Attack and Defense. | 0 | 0 | 0 | ||||||
| Dragon Scale Shield | +3 Attack and Defense. | 0 | 0 | 0 | ||||||
| Dragon Wing Tabard | +2 Spell Power and Knowledge. | 0 | 0 | 0 | ||||||
| Dragonbone Greaves | +1 Spell Power and Knowledge. | 0 | 0 | 0 | ||||||
| Quiet Eye of a Dragon | +1 Attack and Defense. | 0 | 0 | 0 | ||||||
| Red Dragon Flame Tongue | +2 Attack and Defense. | 0 | 0 | 0 | ||||||
| Slithering Sash | +3 Spell Power and Knowledge. | 0 | 0 | 0 | ||||||
| Orb of Dawn | All of the hero’s Daylight spells have +1 level(s). Enemy hero has –1 Daylight spell level. | 0 | 0 | 0 | ||||||
| Orb of Eternity | All of the hero’s Arcane spells have +1 level(s). Enemy hero has –1 Arcane spell level. | 0 | 0 | 0 | ||||||
| Orb of Twilight | All of the hero’s Nightshade spells have +1 level(s). Enemy hero has –1 Nightshade spell level. | 0 | 0 | 0 | ||||||
| Primordial Orb | All of the hero’s Primal spells have +1 level(s). Enemy hero has –1 Primal spell level. | 0 | 0 | 0 | ||||||
| Ring of Neutrality | All creatures always have neutral Luck in battle. | 0 | 0 | 0 | ||||||
| Liquid Silence | +1 round(s) to the cooldown of all enemy creature abilities. | 0 | 0 | 0 | ||||||
| Amelchia's Law | –1 Initiative to enemy creatures. | 0 | 0 | 0 | ||||||
| Truthmaker | –10% Attack to enemy creatures. | 0 | 0 | 0 | ||||||
| Truthseeker | –10% Defense to enemy creatures. | 0 | 0 | 0 | ||||||
| Runestone Shards | Makes all tier-2 spells available to the hero. | 0 | 0 | 0 | ||||||
| Scholar's Amulet | +2 Knowledge. | 0 | 0 | 0 | ||||||
| Scholar's Tiara | +2 Knowledge. | 0 | 0 | 0 | ||||||
| Seal of Silence | +1 round(s) to the cooldown of all enemy spells. | 0 | 0 | 0 | ||||||
| Seven-League Boots | +30 Movement points. | 0 | 0 | 0 | ||||||
| Shackles of War | Prevents surrender and flee in battle. (This affects both the wearer and their opponent.) | 0 | 0 | 0 | ||||||
| Bone Boots | +4 Spell Power, then +15% total Spell Power. | 0 | 0 | 0 | ||||||
| Ribcage Armor | +4 Defense, then +15% total Defense. | 0 | 0 | 0 | ||||||
| Dark Hatchet | +4 Attack, then +15% total Attack. | 0 | 0 | 0 | ||||||
| Second Shade | +4 Knowledge, then +15% total Knowledge. | 0 | 0 | 0 | ||||||
| Clenching Ring | All effects applied by the hero last +1 round(s). | 0 | 0 | 0 | ||||||
| Sirin Mask | The cooldowns of all spells are reduced by 1 round(s). | 0 | 0 | 0 | ||||||
| Iridescent Cloak | +6 Knowledge. | 0 | 0 | 0 | ||||||
| Shaman Staff | +6 Spell Power. | 0 | 0 | 0 | ||||||
| Shoddy Shield | +2 Defense. | 0 | 0 | 0 | ||||||
| Sixth Finger | –1 to enemy Morale and Luck. | 0 | 0 | 0 | ||||||
| Soulless Sash | –1 Morale to enemy creatures. | 0 | 0 | 0 | ||||||
| Soulcaller Ring | The enemy loses 1 levels on all Magic School spells. | 0 | 0 | 0 | ||||||
| Spellbinder's Hat | Makes all tier-5 spells available to the hero. | 0 | 0 | 0 | ||||||
| Spells in Bottles | Makes all tier-4 spells available to the hero. | 0 | 0 | 0 | ||||||
| Spyglass | +2 sight radius. | 0 | 0 | 0 | ||||||
| Swamp Boots | Eliminates all terrain penalties. | 0 | 0 | 0 | ||||||
| Tactical Guide | The opponent cannot rearrange creatures before the start of battle. | 0 | 0 | 0 | ||||||
| Shield of the Rampaging Ogre | +4 Defense. | 0 | 0 | 0 | ||||||
| Mirror Tiara | Restores 8 mana to the hero each morning. | 0 | 0 | 0 | ||||||
| Magic Mirror | Restores 4 mana to the hero each morning. | 0 | 0 | 0 | ||||||
| Shard of Serenity | Restores 6 mana to the hero each morning. | 0 | 0 | 0 | ||||||
| Tunic of the Cyclops King | +4 Spell Power. | 0 | 0 | 0 | ||||||
| Two-faced Mask | The hero can use the Spellbook 1 additional time(s) per battle round. | 0 | 0 | 0 | ||||||
| Tabar Signet-Ring | +1 Luck. | 0 | 0 | 0 | ||||||
| Ukh Signet | +1 Morale. | 0 | 0 | 0 | ||||||
| Voodoo Doll | When the wearer is defeated, they can still be hired back in the Tavern. | 0 | 0 | 0 | ||||||
| Backpack | The hero has +10 Movement points. | 0 | 0 | 0 | ||||||
| Boots of Travel | +10 Movement points. | 0 | 0 | 0 | ||||||
| Warlord Boots | +2 Initiative to friendly creatures. | 0 | 0 | 0 | ||||||
| Warrior's Belt | +2 Attack. | 0 | 0 | 0 | ||||||
| Warrior's Amulet | +2 Attack. | 0 | 0 | 0 | ||||||
| Wizard's Cloak | +2 Spell Power. | 0 | 0 | 0 | ||||||
| Wizard's Amulet | +2 Spell Power. | 0 | 0 | 0 | ||||||
-- 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',
wiki_artifact = 'Artifact',
unit_window_narrative = 'Description'
}
-- 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 .. '🗯️'
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, 'A.slot = slot');
--table.insert(fields, 'A.rarity = rarity');
--table.insert(fields, 'A.artifact_set_id = artifact_set_id');
--table.insert(fields, 'A.goods_value = goods_value');
--table.insert(fields, 'A.max_level = max_level');
--table.insert(fields, 'A.cost_base = cost_base');
--table.insert(fields, 'A.cost_per_level = cost_per_level');
table.insert(fields, 'T.language = language');
table.insert(fields, 'T.name = name');
table.insert(fields, 'T.description = description');
table.insert(fields, 'T.type = type');
-- where:
local where = {}
table.insert(where, 'A.id NOT LIKE "campaign_%"')
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 magic scrolls into 3 artifacts (normal, enchanted and mythic):
------------------------------------------------------------------------------------------------------------------------
local function consolidateScrolls(lang, results)
local hub = {}
for _, row in ipairs(results) do
local id = row.id
if id:find('magic_scroll') then
if id:find('mythic') then
id = 'mythic_scroll_box_artifact'
else
if id:find('enchanted') then
id = 'enchanted_magic_scroll_artifact'
else
id = 'magic_scroll_artifact'
end
end
local entry = hub[id]
if not entry then
entry = {}
entry.id = id or ''
entry.spells = {}
entry.slot = row.slot or ''
entry.rarity = row.rarity or ''
entry.artifact_set_id = row.artifact_set_id or ''
--entry.goods_value = row.goods_value or 0
entry.max_level = row.max_level or 0
entry.cost_base = row.cost_base or 0
entry.cost_per_level = row.cost_per_level or 0
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 ''
local spellId = row.id:gsub('.*artifact_', '')
table.insert(entry.spells, spellId)
end
end
end
return hub
end
-- Folds all Cargo results into a single dictionary:
------------------------------------------------------------------------------------------------------------------------
local function consolidate(lang, results)
local hub = consolidateScrolls(lang, results)
for _, row in ipairs(results) do
local id = row.id
if not id:find('magic_scroll') then
local entry = hub[id]
if not entry then
entry = {}
entry.id = id or ''
entry.slot = row.slot or ''
entry.rarity = row.rarity or ''
entry.artifact_set_id = row.artifact_set_id or ''
--entry.goods_value = row.goods_value or 0
entry.max_level = row.max_level or 0
entry.cost_base = row.cost_base or 0
entry.cost_per_level = row.cost_per_level or 0
hub[id] = entry
end
if row.language == lang then
entry.name = row.name or ''
if row.type == 'artifact' then
entry.description = row.description or ''
end
if row.type == 'artifact_upgrade' then
entry.upgrade = row.description or ''
end
if row.type == 'artifact_narrative' then
entry.narrative = row.description or ''
end
end
if row.language == 'en' then
entry.nameEn = row.name or ''
end
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
-- TABLE HEADER
------------------------------------------------------------------------------------------------------------------------
local function createHeader(htmlTable, words)
local tr = htmlTable:tag('tr')
--addTh(tr, 'id')
addTh(tr, words.wiki_artifact):attr('colspan', 2)
addTh(tr, words.unit_window_narrative)
addTh(tr, 'upgrade')
--addTh(tr, 'narrative')
addTh(tr, 'slot')
addTh(tr, 'rarity')
addTh(tr, 'artifact_set_id')
--addTh(tr, 'goods_value')
addTh(tr, 'max_level')
addTh(tr, 'cost_base')
addTh(tr, 'cost_per_level')
end
------------------------------------------------------------------------------------------------------------------------
local function renderIcon(id, nameEn, lang)
local url = getUrl(nameEn, lang)
return f('[[File:%s.png|64px|link=%s]]', id, url)
end
------------------------------------------------------------------------------------------------------------------------
local function renderName(name, nameEn, lang)
local url = getUrl(nameEn, lang)
return f('[[%s|%s]]', url, name)
end
-- TABLE BODY
------------------------------------------------------------------------------------------------------------------------
local function createBody(htmlTable, list, lang)
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, renderIcon(item.id, item.nameEn, lang))
addTd(tr, renderName(item.name, item.nameEn, lang))
addTd(tr, item.description)
addTd(tr, item.upgrade)
--addTd(tr, item.narrative)
addTd(tr, item.slot)
addTd(tr, item.rarity)
addTd(tr, item.artifact_set_id)
addTd(tr, item.goods_value)
addTd(tr, item.max_level)
addTd(tr, item.cost_base)
addTd(tr, item.cost_per_level)
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, words)
createBody(htmlTable, list, lang)
-- Output
local styleTag = frame:extensionTag('templatestyles', '', { src = frame:getTitle() .. '/styles.css' })
return '<div class="artifacts-overview">' .. styleTag .. tostring(htmlTable) .. '</div>'
end
return p


