Module:ItemList/Test SMW
From Fallen London Wiki
Documentation for this module may be created at Module:ItemList/Test SMW/doc
local p = {}
local Burden = mw.loadData('Module:ItemList/Burden')
local Hat = mw.loadData('Module:ItemList/Hats')
local Clothing = mw.loadData('Module:ItemList/Clothing')
local Gloves = mw.loadData('Module:ItemList/Gloves')
local Weapon = mw.loadData('Module:ItemList/Weapons')
local Boots = mw.loadData('Module:ItemList/Boots')
local Companion = mw.loadData('Module:ItemList/Companions')
local Treasure = mw.loadData('Module:ItemList/Treasures')
local Destiny = mw.loadData('Module:ItemList/Destinies')
local Affiliation = mw.loadData('Module:ItemList/Affiliations')
local Transport = mw.loadData('Module:ItemList/Transport')
local HomeComfort = mw.loadData('Module:ItemList/Home Comforts')
local Ship = mw.loadData('Module:ItemList/Ships')
local Spouse = mw.loadData('Module:ItemList/Spouses')
local Club = mw.loadData('Module:ItemList/Clubs')
local function smw_fetch_items(class)
local extendedResult = mw.smw.getQueryResult("[[Equips in slot::" .. class .. [===[ ]]
[[!The Imperturbable Patroness]]
|?=Item
|?Has effect#-=Effects
|?Category:Fate Items=Fate
|?-Has renown item=Faction
|?-Has profession item=Profession
|?Category:Mood
|?Category:SMEN
|?Category:Knife-and-Candle Medals=Knife & Candle
|?Category:Connected Pet
|?Category:Ambition: Light Fingers! Items=Light Fingers!
|?Category:Ambition: Heart's Desire! Items=Heart's Desire!
|?Category:Ambition: Nemesis Items=Nemesis
|?Category:Ambition: Bag a Legend! Items=Bag a Legend!
|?Category:Retired Items=Retired
|?Category:Hallowmas Equipment=Hallowmas
|?Category:Feast of the Rose Equipment=Rose
|?Category:Christmas Equipment=Christmas
|?Category:Election Equipment=Election
|?Category:Grand Clearing-Out Equipment=Grand Clearing-Out
|?Category:Fruits of the Zee Equipment=Fruits
|?Category:Whitsun Equipment=Whitsun
|?Category:Sunless Sea Items=Sunless Sea
|?Category:Sunless Skies Items=Sunless Skies
|?Category:Mask of the Rose Items=Mask of the Rose
|?Category:Protégé Items=Protege
|?Category:Fallen London Mysteries=Mysteries
|limit=1000
]===]);
local results = {};
for i, item in ipairs(extendedResult.results) do
local name = item.fulltext;
local quals = {};
for q, b in pairs(item.printouts) do
if b[1] == "t" then
table.insert(quals, q);
elseif q == "Faction" and #b == 1 then
table.insert(quals, string.sub(b[1].fulltext, 10)); -- strip "Faction: "
elseif q == "Profession" and #b == 1 then
table.insert(quals, b[1].fulltext);
end
end
local effs = {};
for j, e in ipairs(item.printouts.Effects) do
effs[e["Modifies quality"].item[1].fulltext] = e["Modifies by"].item[1];
end
results[name] = {effects = effs, qualifiers = quals,};
end
return results;
end
local item_class = {
["Burden"] = Burden,
["Hat"] = Hat,
["Clothing"] = Clothing,
["Gloves"] = Gloves,
["Weapon"] = Weapon,
["Boots"] = Boots,
["Companion"] = Companion,
["Treasure"] = Treasure,
["Destiny"] = Destiny,
["Affiliation"] = Affiliation,
["Transport"] = Transport,
["Home Comfort"] = HomeComfort,
["Ship"] = Ship,
["Spouse"] = Spouse,
["Club"] = Club,
}
function p.find_diffs(frame)
local acc = {}
for classname, classlist in pairs(item_class) do
table.insert(acc, "==" .. classname .. "==")
local smwitems = smw_fetch_items(classname)
for item, details in pairs(classlist) do
if smwitems[item] then
if details.qualifiers then
local ilq = {}
for _, qual in pairs(details.qualifiers) do
table.insert(ilq, qual)
end
local smwq = smwitems[item].qualifiers or {}
table.sort(ilq)
table.sort(smwq)
local ils = table.concat(ilq, ", ")
local smws = table.concat(smwq, ", ")
if ils ~= smws then
table.insert(acc, "* Mismatched quals:" .. item .. " - " .. ils .. " vs " .. smws)
end
end
else
table.insert(acc, "* Missing from SMW: " .. item)
end
end
end
return table.concat(acc, "\n")
end
return p