Anonymous

Module:Skills/Cartography: Difference between revisions

From Melvor Idle
getPointOfInterestTable: Fix active modifiers
No edit summary
(getPointOfInterestTable: Fix active modifiers)
Line 6: Line 6:


local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Constants = require('Module:Constants')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Items = require('Module:Items')
local Items = require('Module:Items')
local Common = require('Module:Common')
local Common = require('Module:Common')
Line 125: Line 125:
local Hex = p.getHexByAxial(POI.coords)
local Hex = p.getHexByAxial(POI.coords)
local reqTable = {}
local reqTable = {}
local HexReqs = Common.getRequirementString(Hex.requirements, '')
local HexReqs = (Hex ~= nil and Common.getRequirementString(Hex.requirements, '')) or ''
if HexReqs ~= '' then
if HexReqs ~= '' then
table.insert(reqTable, HexReqs)
table.insert(reqTable, HexReqs)
Line 185: Line 185:
local modText, rewardTextPart = nil, {}
local modText, rewardTextPart = nil, {}
if bonus.modifiers ~= nil and not Shared.tableIsEmpty(bonus.modifiers) then
if bonus.modifiers ~= nil and not Shared.tableIsEmpty(bonus.modifiers) then
modText = Constants.getModifiersText(bonus.modifiers, true, false)
modText = Modifiers.getModifiersText(bonus.modifiers, true, false)
end
end
if bonus.items ~= nil then
if bonus.items ~= nil then
Line 245: Line 245:
for i, POI in pairs(POIs) do
for i, POI in pairs(POIs) do
local meetsCondition = true
local meetsCondition = true
local poiDiscoveryMods = POI.discoveryModifiers
local poiActiveStats = POI.activeStats
if discoveryModifier ~= nil and discoveryModifier ~= '' then
if discoveryModifier ~= nil and discoveryModifier ~= '' then
if POI.discoveryModifiers ~= nil then
if poiDiscoveryMods ~= nil then
local modifierText = Constants.getModifiersText(POI.discoveryModifiers.modifiers)..' (for '..POI.discoveryModifiers.moves..' travels)'
local modifierText = Modifiers.getModifiersText(poiDiscoveryMods.modifiers)..' (for '..poiDiscoveryMods.moves..' travels)'
meetsCondition = meetsCondition and string.find(modifierText, discoveryModifier)
meetsCondition = meetsCondition and string.find(modifierText, discoveryModifier) ~= nil
else
else
meetsCondition = false
meetsCondition = false
Line 256: Line 258:
if activeModifier ~= nil and activeModifier ~= '' then
if activeModifier ~= nil and activeModifier ~= '' then
if POI.activeModifiers ~= nil then
if poiActiveStats ~= nil and poiActiveStats.modifiers ~= nil then
local modifierText = Constants.getModifiersText(POI.activeModifiers)
local modifierText = Modifiers.getModifiersText(poiActiveStats.modifiers)
meetsCondition = meetsCondition and string.find(modifierText, activeModifier)
meetsCondition = meetsCondition and string.find(modifierText, activeModifier) ~= nil
else
else
meetsCondition = false
meetsCondition = false
Line 281: Line 283:
POIType = 'Dig Site'
POIType = 'Dig Site'
else
else
if POI.activeModifiers ~= nil then
if POI.activeStats ~= nil and not Shared.tableIsEmpty(POI.activeStats) then
POIType = 'Active'
POIType = 'Active'
elseif POI.fastTravel ~= nil then
elseif POI.fastTravel ~= nil then
Line 303: Line 305:
--Add Discovery Modifiers
--Add Discovery Modifiers
table.insert(tableStr, '\r\n|')
table.insert(tableStr, '\r\n|')
if POI.discoveryModifiers ~= nil then
if poiDiscoveryMods ~= nil then
table.insert(tableStr, Constants.getModifiersText(POI.discoveryModifiers.modifiers)..' (for '..POI.discoveryModifiers.moves..' travels)')
table.insert(tableStr, Modifiers.getModifiersText(poiDiscoveryMods.modifiers)..' (for '..poiDiscoveryMods.moves..' travels)')
end
end
--Add Active Modifiers
--Add Active Modifiers
table.insert(tableStr, '\r\n|')
table.insert(tableStr, '\r\n|')
if POI.activeModifiers ~= nil then
if poiActiveStats ~= nil and poiActiveStats.modifiers ~= nil then
table.insert(tableStr, Constants.getModifiersText(POI.activeModifiers))
table.insert(tableStr, Modifiers.getModifiersText(poiActiveStats.modifiers))
end
end
end
end
Line 367: Line 369:
local items = {}
local items = {}
for itemName in string.gmatch(itemNames, "[^,]*") do
for itemName in string.gmatch(itemNames, "[^,]*") do
item = Items.getItem(itemName)
local item = Items.getItem(itemName)
if item ~= nil then
if item ~= nil then
table.insert(items, item)
table.insert(items, item)
Line 428: Line 430:
    -- no tile here
    -- no tile here
    else
    else
item = p.hex({args={x=x, y=y}})
local item = p.hex({args={x=x, y=y}})
table.insert(testTable, item)
table.insert(testTable, item)
    end
    end