17,081
edits
(_getCreationTable: Correct base quantity & experience for Farming) |
(_getItemSourceTables, _getItemSources: Support Township trading sources) |
||
Line 468: | Line 468: | ||
break | break | ||
end | end | ||
end | |||
end | |||
-- Township trading | |||
for i, tsResource in ipairs(SkillData.Township.itemConversions.fromTownship) do | |||
local found = false | |||
for j, tradeDef in ipairs(tsResource.items) do | |||
if tradeDef.itemID == item.id then | |||
found = true | |||
local levelReq = nil | |||
if tradeDef.unlockRequirements ~= nil then | |||
for k, req in ipairs(tradeDef.unlockRequirements) do | |||
if req.type == 'SkillLevel' and req.skillID == 'melvorD:Township' then | |||
levelReq = req.level | |||
break | |||
end | |||
end | |||
if levelReq == nil then | |||
table.insert(lineArray, Icons.Icon({SkillData.Township.name, type='skill'})) | |||
else | |||
table.insert(lineArray, Icons._SkillReq(SkillData.Township.name, levelReq)) | |||
end | |||
end | |||
end | |||
if found then | |||
break | |||
end | |||
end | |||
if found then | |||
break | |||
end | end | ||
end | end | ||
Line 597: | Line 627: | ||
end | end | ||
--Township Task reward | -- Township Task reward | ||
for _, task in ipairs(SkillData.Township.tasks) do | for _, task in ipairs(SkillData.Township.tasks) do | ||
if task.rewards.items[1] ~= nil then -- Skip tasks with no items | if task.rewards.items[1] ~= nil then -- Skip tasks with no items | ||
Line 930: | Line 960: | ||
return p._getItemSuperheatTable(item) | return p._getItemSuperheatTable(item) | ||
end | |||
function p._getTownshipTraderTable(item) | |||
for i, tsResource in ipairs(SkillData.Township.itemConversions.fromTownship) do | |||
for j, tradeDef in ipairs(tsResource.items) do | |||
if tradeDef.itemID == item.id then | |||
-- Item found, build table | |||
local res = GameData.getEntityByID(SkillData.Township.resources, tsResource.resourceID) | |||
local resName = (res ~= nil and res.name) or 'Unknown' | |||
local resQty = math.max(item.sellsFor, 2) | |||
local resultPart = {} | |||
table.insert(resultPart, '{| class="wikitable"\n|-') | |||
table.insert(resultPart, '\n!colspan="2"| ' .. Icons.Icon({'Township', 'Trader', type='skill'})) | |||
table.insert(resultPart, '\n|-\n!style="text-align:right;"| Cost') | |||
table.insert(resultPart, '\n| ' .. Icons.Icon({resName, qty=resQty, type='resource'})) | |||
table.insert(resultPart, '\n|-\n!style="text-align:right;| Requirements') | |||
table.insert(resultPart, '\n| ' .. Shop.getRequirementString(tradeDef.unlockRequirements)) | |||
table.insert(resultPart, '\n|}') | |||
return table.concat(resultPart) | |||
end | |||
end | |||
end | |||
return '' | |||
end | end | ||
Line 950: | Line 1,005: | ||
if creationTable ~= '' then table.insert(resultPart, '===Creation===\r\n') end | if creationTable ~= '' then table.insert(resultPart, '===Creation===\r\n') end | ||
table.insert(resultPart, upgradeTable) | table.insert(resultPart, upgradeTable) | ||
end | |||
local townshipTable = p._getTownshipTraderTable(item) | |||
if townshipTable ~= '' then | |||
if not Shared.tableIsEmpty(resultPart) then table.insert(resultPart, '\n') end | |||
table.insert(resultPart, '===Township===\n' .. townshipTable) | |||
end | end | ||
Line 1,073: | Line 1,134: | ||
'Gem Gloves', | 'Gem Gloves', | ||
"Thief's Moneysack", | "Thief's Moneysack", | ||
"Golden Stardust" | "Golden Stardust", | ||
"Golden Star", | |||
"Slayer Deterer" | |||
} | } | ||
local checkFuncs = { | local checkFuncs = { |