17,105
edits
No edit summary |
(getMatchCriteriaFromIDs: Fix processing of scopes from modifier IDs) |
||
Line 184: | Line 184: | ||
end | end | ||
-- Add all scopes | |||
for _, allowedScope in ipairs(modDefn.allowedScopes) do | for _, allowedScope in ipairs(modDefn.allowedScopes) do | ||
table.insert(matchCriteria, { | |||
["mod"] = modDefn, | |||
["scope"] = allowedScope.scopes or {} | |||
}) | |||
end | end | ||
end | end | ||
Line 656: | Line 646: | ||
function p.test3() | function p.test3() | ||
local item = GameData.getEntityByID('items', ' | local item = GameData.getEntityByID('items', 'melvorF:Miners_Helmet') | ||
local matchCriteria = { | local matchCriteria = { | ||
{ | { | ||
Line 664: | Line 654: | ||
--} | --} | ||
-- Should no longer match if changed to increased | -- Should no longer match if changed to increased | ||
["alias"] = ' | ["alias"] = 'increasedChanceNoDamageMining', | ||
}, | }, | ||
{ | { | ||
Line 700: | Line 690: | ||
return p.getModifierValue(matchedMods.matched) | return p.getModifierValue(matchedMods.matched) | ||
--return p.getMatchingModifiers(purch.contains.modifiers, matchCriteria) | --return p.getMatchingModifiers(purch.contains.modifiers, matchCriteria) | ||
end | |||
-- Checks p.getMatchCriteriaFromIDs() and p.getMatchingModifiers() | |||
-- Any entity processed by this should return a table with all modifiers | |||
-- matched and none unmatched. Unmatched modifiers implies an issue with one | |||
-- of the aforementioned functions | |||
function p.test5() | |||
local ent = GameData.getEntityByID('items', 'melvorF:Miners_Helmet') | |||
local entMods = ent.modifiers | |||
if entMods ~= nil then | |||
local modIDs = {} | |||
for modID, modDet in pairs(entMods) do | |||
table.insert(modIDs, modID) | |||
end | |||
local matchCriteria = p.getMatchCriteriaFromIDs(modIDs, nil) | |||
mw.logObject(matchCriteria) | |||
mw.log('=======================================================') | |||
local matchingMods = p.getMatchingModifiers(entMods, matchCriteria) | |||
return matchingMods | |||
end | |||
return nil | |||
end | end | ||
return p | return p |