572
edits
No edit summary |
No edit summary |
||
Line 204: | Line 204: | ||
-- Get the list of convertable items, and calculates each item's exchange rate | -- Get the list of convertable items, and calculates each item's exchange rate | ||
-- See township.js -> TownshipResource.buildResourceItemConversions for the calculation of valid items | -- See township.js -> TownshipResource.buildResourceItemConversions for the calculation of valid items | ||
local function matchNone(item) | |||
return false | |||
end | |||
local function matchFood(item) | local function matchFood(item) | ||
return item.type == 'Food' and (not string.match(item.id, '_Perfect')) and item.category ~= 'Farming' and (not item.ignoreCompletion) | return item.type == 'Food' and (not string.match(item.id, '_Perfect')) and item.category ~= 'Farming' and (not item.ignoreCompletion) | ||
end | end | ||
local function matchLogs(item) | |||
return item.type == 'Logs' | |||
end | |||
local function matchOre(item) | |||
return item.type == 'Ore' and item.id ~= 'melvorTotH:Meteorite_Ore' | |||
end | |||
local function matchCoal(item) | |||
return item.id ~= 'melvorD:Coal_Ore' | |||
end | |||
local function matchBar(item) | |||
return item.type == 'Bar' and item.id ~= 'melvorTotH:Meteorite_Bar' | |||
end | |||
local function matchHerb(item) | |||
return item.type == 'Herb' | |||
end | |||
local function matchEssence(item) | |||
return item.id == 'melvorD:Rune_Essence' or item.id == 'melvorTotH:Pure_Essence' | |||
end | |||
local function matchLeather(item) | |||
return item.id == 'melvorD:Leather' | |||
end | |||
local function matchPotion(item) | |||
return item.type == 'Potion' and string.match(item.id, '_IV') | |||
end | |||
local function matchClothing(item) | |||
local valid_tiers = {'Leather', 'Hard Leather', 'Dragonhide', 'Elderwood', 'Revenant', 'Carrion'} | |||
for _, tier in ipairs(valid_tiers) do | |||
if item.tier == tier then | |||
return true | |||
end | end | ||
end | end | ||
return false | |||
end | |||
local resource_data = { | |||
['melvorF:GP'] = {_tradermatches = matchNone}, | |||
['melvorF:Food'] = {_tradermatches = matchFood}, | |||
['melvorF:Wood'] = {_tradermatches = matchLogs}, | |||
['melvorF:Stone'] = {_tradermatches = matchOre}, | |||
['melvorF:Ore'] = {_tradermatches = matchOre}, | |||
['melvorF:Coal'] = {_tradermatches = matchCoal}, | |||
['melvorF:Bar'] = {_tradermatches = matchBar}, | |||
['melvorF:Herbs'] = {_tradermatches = matchHerb}, | |||
['melvorF:Rune_Essence'] = {_tradermatches = matchEssence}, | |||
['melvorF:Leather'] = {_tradermatches = matchLeather}, | |||
['melvorF:Potions'] = {_tradermatches = matchPotion}, | |||
['melvorF:Planks'] = {_tradermatches = matchLogs}, | |||
['melvorF:Clothing'] = {_tradermatches = matchClothing} | |||
} | |||
for _, resource in ipairs(resources) do | |||
resource.itemConversions = Shared.clone(GameData.getEntities('items', resource_data[resource.id]._tradermatches)) | |||
end | end | ||
edits