Anonymous

Module:Items/SourceTables/Sandbox: Difference between revisions

From Melvor Idle
Synced with live
(getItemSourceTables: Format monster combat level)
(Synced with live)
Line 3: Line 3:
local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Common = require('Module:Common')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Magic = require('Module:Magic')
local Magic = require('Module:Magic')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
Line 11: Line 13:
local Monsters = require('Module:Monsters')
local Monsters = require('Module:Monsters')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local Num = require('Module:Number')


local SourceOverrides = {
local SourceOverrides = {
['melvorAoD:EarthGolem'] = 'Earth Golem (AoD)'
['melvorAoD:EarthGolem'] = 'Earth Golem (AoD)'
}
}
local function doesRecipeHaveItemID(recipe, itemID)
if recipe.productId == itemID then
return true, nil
elseif type(recipe.products) == 'table' then
for i, product in ipairs(recipe.products) do
if product.itemID == itemID then
local specialReq = nil
if recipe.products[i].minIntensityPercent ~= nil then
specialReq = recipe.products[i].minIntensityPercent .. '% Intensity'
end
return true, specialReq
end
end
end
return false, nil
end


function p._getCreationTable(item)
function p._getCreationTable(item)
local skill = ''
local skill = ''
local specialReq = nil
local specialReq = nil
local category = nil
local time = 0
local time = 0
local maxTime = nil
local maxTime = nil
local lvl = 0
local lvl = 0
local isAbyssal = false
local xp = 0
local xp = 0
local qty = nil
local qty = nil
Line 35: Line 57:
['Fishing'] = { recipeKey = 'fish' },
['Fishing'] = { recipeKey = 'fish' },
['Mining'] = { recipeKey = 'rockData' },
['Mining'] = { recipeKey = 'rockData' },
['Farming'] = { recipeKey = 'recipes' }
['Farming'] = { recipeKey = 'recipes' },
['Harvesting'] = { recipeKey = 'veinData' }
},
},
['Artisan'] = {
['Artisan'] = {
Line 53: Line 76:
local skillData = SkillData[localSkillID]
local skillData = SkillData[localSkillID]
local skill = skillData.name
local skill = skillData.name
local lvl, xp, qty, req, time, maxTime = 0, 0, 0, nil, 0, nil
local lvl, isAbyssal, xp, qty, req, category, time, maxTime = 0, false, 0, 0, nil, nil, 0, nil
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do
if recipe.productId == itemID then
local hasProduct, specialReq = doesRecipeHaveItemID(recipe, itemID)
lvl = recipe.level
if hasProduct then
xp = recipe.baseExperience
lvl, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe)
xp = recipe.baseAbyssalExperience or recipe.baseExperience
qty = recipe.baseQuantity or 1
qty = recipe.baseQuantity or 1
if localSkillID == 'Farming' then
if localSkillID == 'Farming' then
req = { recipe.seedCost }
req = { recipe.seedCost }
local category = GameData.getEntityByID(skillData.categories, recipe.categoryID)
local catData = GameData.getEntityByID(skillData.categories, recipe.categoryID)
qty = 5 * category.harvestMultiplier
category = catData.name
qty = 5 * catData.harvestMultiplier
end
end
-- Action time
-- Action time
Line 77: Line 102:
-- Special requirements
-- Special requirements
if recipe.totalMasteryRequired ~= nil then
if recipe.totalMasteryRequired ~= nil then
specialReq = Icons.Icon({'Mastery', notext=true}) .. Shared.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]'
specialReq = Icons.Icon({'Mastery', notext=true}) .. Num.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]'
end
end
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, category, time, maxTime, specialReq))
-- Assumes item has a single source per skill
-- Assumes item has a single source per skill
break
break
Line 91: Line 116:
local skillData = SkillData[localSkillID]
local skillData = SkillData[localSkillID]
local skill = skillData.name
local skill = skillData.name
local lvl, xp, qty, req, time, maxTime = 0, 0, 0, nil, 0, nil
local lvl, isAbyssal, xp, qty, category, req, time, maxTime = 0, false, 0, 0, nil, nil, 0, nil
for i, recipe in ipairs(skillData.recipes) do
for i, recipe in ipairs(skillData.recipes) do
if recipe.productID == itemID or
if recipe.productID == itemID or
(localSkillID == 'Cooking' and recipe.perfectCookID == itemID) or
(localSkillID == 'Cooking' and recipe.perfectCookID == itemID) or
(localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, itemID)) then
(localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, itemID)) then
lvl = recipe.level
lvl, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe)
xp = recipe.baseExperience
xp = recipe.baseAbyssalExperience or recipe.baseExperience
qty = recipe.baseQuantity or 1
qty = recipe.baseQuantity or 1
-- Recipe Category
if recipe.categoryID ~= nil then
local catData = GameData.getEntityByID(SkillData[localSkillID].categories, recipe.categoryID)
category = catData.modifierName or catData.name or nil
end
-- Action time
-- Action time
if recipe.baseMinInterval ~= nil then
if recipe.baseMinInterval ~= nil then
Line 122: Line 152:
if localSkillID == 'Summoning' then
if localSkillID == 'Summoning' then
local shardCostArray, otherCostArray = {}, {}
local shardCostArray, otherCostArray = {}, {}
local recipeGPCost = skillData.recipeGPCost
local recipeCost = 0
if isAbyssal == true then
recipeCost = skillData.recipeAPCost
else
recipeCost = skillData.recipeGPCost
end
-- Shards
-- Shards
for j, itemCost in ipairs(recipe.itemCosts) do
for j, itemCost in ipairs(recipe.itemCosts) do
Line 131: Line 166:
end
end
-- Other costs
-- Other costs
if recipe.gpCost > 0 then
table.insert(otherCostArray, Common.getCostString({ ["items"] = {}, ["currencies"] = recipe.currencyCosts}))
table.insert(otherCostArray, Icons.GP(recipe.gpCost))
end
if recipe.scCost > 0 then
table.insert(otherCostArray, Icons.SC(recipe.scCost))
end
for j, nonShardID in ipairs(recipe.nonShardItemCosts) do
for j, nonShardID in ipairs(recipe.nonShardItemCosts) do
local nonShard = Items.getItemByID(nonShardID)
local nonShard = Items.getItemByID(nonShardID)
if nonShard ~= nil then
if nonShard ~= nil then
local itemValue = math.max(nonShard.sellsFor, 20)
local itemValue = math.max(nonShard.sellsFor, 20)
local nonShardQty = math.max(1, math.floor(recipeGPCost / itemValue))
local nonShardQty = math.max(1, math.ceil(recipeCost / itemValue))
table.insert(otherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty}))
table.insert(otherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty}))
end
end
Line 151: Line 181:
end
end
specialReq = 'At least 1 ' .. Icons.Icon({'Summoning%23Summoning Marks', item.name, img=item.name, type='mark'}) .. ' mark discovered'
specialReq = 'At least 1 ' .. Icons.Icon({'Summoning%23Summoning Marks', item.name, img=item.name, type='mark'}) .. ' mark discovered'
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, nil, specialReq))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, category, time, nil, specialReq))
-- Some items (such as Arrow shafts) have multiple recipes
-- Some items (such as Arrow shafts) have multiple recipes
elseif type(recipe.alternativeCosts) == 'table' then
elseif type(recipe.alternativeCosts) == 'table' then
Line 165: Line 195:
end
end
end
end
if recipe.gpCost ~= nil and recipe.gpCost > 0 then
 
table.insert(reqSubPart, Icons.GP(recipe.GPCost))
table.insert(reqSubPart, Common.getCostString({ ["items"] = {}, ["currencies"] = recipe.currencyCosts}))
end
if recipe.scCost ~= nil and recipe.scCost > 0 then
table.insert(reqSubPart, Icons.SC(recipe.SCCost))
end
table.insert(reqPart, table.concat(reqSubPart, ', '))
table.insert(reqPart, table.concat(reqSubPart, ', '))
table.insert(qtyPart, Shared.formatnum(qty * altCost.quantityMultiplier))
table.insert(qtyPart, Num.formatnum(qty * altCost.quantityMultiplier))
end
end
local sep = "<br/>'''OR''' "
local sep = "<br/>'''OR''' "
req = table.concat(reqPart, sep)
req = table.concat(reqPart, sep)
local qtyText = table.concat(qtyPart, sep)
local qtyText = table.concat(qtyPart, sep)
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qtyText, time, maxTime, specialReq))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qtyText, category, time, maxTime, specialReq))
-- Finally, normal recipes with a single set of item costs
-- Finally, normal recipes with a single set of item costs
elseif type(recipe.itemCosts) == 'table' and not Shared.tableIsEmpty(recipe.itemCosts) then
elseif type(recipe.itemCosts) == 'table' and not Shared.tableIsEmpty(recipe.itemCosts) then
table.insert(tables, p.buildCreationTable(skill, lvl, xp, recipe.itemCosts, qty, time, maxTime, specialReq, recipe.gpCost, recipe.scCost))
table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, recipe.itemCosts, qty, category, time, maxTime, specialReq, recipe.currencyCosts))
end
end
end
end
Line 237: Line 263:
end
end


function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq, gpCost, scCost)
function p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, category, time, maxTime, specialReq, currencyCost)
if qty == nil then qty = 1 end
if qty == nil then qty = 1 end
local resultPart = {}
local resultPart = {}
Line 243: Line 269:
table.insert(resultPart, '\r\n!colspan="2"|Item ' .. (req == nil and 'Creation' or 'Production'))
table.insert(resultPart, '\r\n!colspan="2"|Item ' .. (req == nil and 'Creation' or 'Production'))
table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Requirements')
table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Requirements')
table.insert(resultPart, '\r\n|'..Icons._SkillReq(skill, lvl))
table.insert(resultPart, '\r\n|'..Icons._SkillReq(skill, lvl, false, (isAbyssal and "melvorItA:Abyssal" or nil)))
if specialReq ~= nil then table.insert(resultPart, '<br/>'..specialReq) end
if specialReq ~= nil then table.insert(resultPart, '<br/>'..specialReq) end


Line 258: Line 284:
end
end
end
end
if gpCost ~= nil and gpCost > 0 then
table.insert(resultPart, '<br/>')
if currencyCost ~= nil then
table.insert(resultPart, Icons.GP(gpCost))
table.insert(resultPart, Common.getCostString({ ["items"] = {}, ["currencies"] = currencyCost }))
end
if scCost ~= nil and scCost > 0 then
table.insert(resultPart, '<br/>')
table.insert(resultPart, Icons.SC(scCost))
end
end
else
else
table.insert(resultPart, req)
table.insert(resultPart, req)
end
end
end
if category ~= nil then
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Recipe Category')
table.insert(resultPart, '\r\n|'..category)
end
end
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Quantity')
table.insert(resultPart, '\r\n|'..qty)
table.insert(resultPart, '\r\n|'..qty)
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Experience')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Experience')
table.insert(resultPart, '\r\n|'..Shared.formatnum(xp)..' XP')
table.insert(resultPart, '\r\n|'..Num.formatnum(xp)..' XP')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Creation Time')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Base Creation Time')
table.insert(resultPart, '\r\n|'..Shared.timeString(time, true))
table.insert(resultPart, '\r\n|'..Shared.timeString(time, true))
Line 292: Line 318:
end
end


function p._getItemSources(item, asList, addCategories)
function p._getItemSources(item, asList, addCategories, separator)
local lineArray = {}
local lineArray = {}
local categoryArray = {}
local categoryArray = {}
local sep = separator or ','


--Alright, time to go through all the ways you can get an item...
--Alright, time to go through all the ways you can get an item...
Line 330: Line 357:
-- Is the item dropped from any dungeon?
-- Is the item dropped from any dungeon?
local dungeonStrPart = {}
local dungeonStrPart = {}
for i, dungeon in ipairs(GameData.rawData.dungeons) do
local dungeonEntities = {
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or
['Dungeon'] = GameData.rawData.dungeons,
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then
['The Abyss'] = GameData.rawData.abyssDepths
table.insert(dungeonStrPart, Icons.Icon({dungeon.name, type='dungeon', notext=true}))
}
elseif dungeon.eventID ~= nil then
for entity, dungeons in pairs(dungeonEntities) do
-- Is the item dropped from a combat event (e.g. Impending Darkness event)?
local iconType = entity == 'Dungeon' and 'dungeon' or 'combatArea'
local event = GameData.getEntityByID('combatEvents', dungeon.eventID)
for i, dungeon in ipairs(dungeons) do
if type(event) == 'table' and type(event.itemRewardIDs) == 'table' then
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or
for eventCycle, itemRewardID in ipairs(event.itemRewardIDs) do
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then
if item.id == itemRewardID then
table.insert(dungeonStrPart, Icons.Icon({dungeon.name, type=iconType, notext=true}))
local dungPrefix = (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or eventCycle .. (eventCycle == 1 and ' cycle' or ' cycles') .. ' of ')
elseif dungeon.eventID ~= nil then
table.insert(dungeonStrPart, dungPrefix .. Icons.Icon({dungeon.name, type='dungeon', notext=true}))
-- Is the item dropped from a combat event (e.g. Impending Darkness event)?
break
local event = GameData.getEntityByID('combatEvents', dungeon.eventID)
if type(event) == 'table' and type(event.itemRewardIDs) == 'table' then
for eventCycle, itemRewardID in ipairs(event.itemRewardIDs) do
if item.id == itemRewardID then
local dungPrefix = (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or eventCycle .. (eventCycle == 1 and ' cycle' or ' cycles') .. ' of ')
table.insert(dungeonStrPart, dungPrefix .. Icons.Icon({dungeon.name, type=iconType, notext=true}))
break
end
end
end
end
end
end
for i, stronghold in ipairs(GameData.rawData.strongholds) do
for tier, tierData in pairs(stronghold.tiers) do
if type(tierData.rewards) == 'table' and type(tierData.rewards.items) == 'table' then
for i, reward in ipairs(tierData.rewards.items) do
if reward.id == item.id then
table.insert(dungeonStrPart, Icons.Icon({stronghold.name, type='combatArea', notext=true}))
end
end
end
end
Line 350: Line 396:


if not Shared.tableIsEmpty(dungeonStrPart) then
if not Shared.tableIsEmpty(dungeonStrPart) then
table.insert(lineArray, 'Completing: ' .. table.concat(dungeonStrPart, ','))
table.insert(lineArray, 'Completing: ' .. table.concat(dungeonStrPart, sep))
end
end
if not Shared.tableIsEmpty(killStrPart) then
if not Shared.tableIsEmpty(killStrPart) then
table.insert(lineArray, 'Killing: ' .. table.concat(killStrPart, ','))
table.insert(lineArray, 'Killing: ' .. table.concat(killStrPart, sep))
end
end


Line 370: Line 416:


if not Shared.tableIsEmpty(lootPart) then
if not Shared.tableIsEmpty(lootPart) then
table.insert(lineArray, 'Opening: ' .. table.concat(lootPart, ','))
table.insert(lineArray, 'Opening: ' .. table.concat(lootPart, sep))
end
end


Line 395: Line 441:
end
end
local typeText = (catName == 'up' and 'Upgrading') or 'Downgrading'
local typeText = (catName == 'up' and 'Upgrading') or 'Downgrading'
table.insert(lineArray, typeText .. ': ' .. table.concat(parts, ','))
table.insert(lineArray, typeText .. ': ' .. table.concat(parts, sep))
end
end
end
end
Line 414: Line 460:
end
end
if not Shared.tableIsEmpty(thiefPart) then
if not Shared.tableIsEmpty(thiefPart) then
table.insert(lineArray, 'Pickpocketing: ' .. table.concat(thiefPart, ','))
table.insert(lineArray, 'Pickpocketing: ' .. table.concat(thiefPart, sep))
end
end
end
end
Line 424: Line 470:
end
end
if not Shared.tableIsEmpty(castPart) then
if not Shared.tableIsEmpty(castPart) then
table.insert(lineArray, 'Casting: ' .. table.concat(castPart, ','))
table.insert(lineArray, 'Casting: ' .. table.concat(castPart, sep))
end
end


Line 433: Line 479:
['Fishing'] = { recipeKey = 'fish' },
['Fishing'] = { recipeKey = 'fish' },
['Mining'] = { recipeKey = 'rockData' },
['Mining'] = { recipeKey = 'rockData' },
['Farming'] = { recipeKey = 'recipes' }
['Farming'] = { recipeKey = 'recipes' },
['Harvesting'] = { recipeKey = 'veinData' }
},
},
['Artisan'] = {
['Artisan'] = {
Line 451: Line 498:
local skill = skillData.name
local skill = skillData.name
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do
if recipe.productId == item.id then
local hasProduct = doesRecipeHaveItemID(recipe, item.id)
if hasProduct then
if localSkillID == 'Farming' and recipe.seedCost ~= nil then
if localSkillID == 'Farming' and recipe.seedCost ~= nil then
local seedItem = Items.getItemByID(recipe.seedCost.id)
local seedItem = Items.getItemByID(recipe.seedCost.id)
Line 458: Line 506:
end
end
else
else
table.insert(lineArray, Icons._SkillReq(skill, recipe.level))
local level, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe)
table.insert(lineArray, Icons._SkillReq(skill, level, false, (isAbyssal and "melvorItA:Abyssal" or nil)))
end
end
break
break
Line 473: Line 522:
(localSkillID == 'Cooking' and recipe.perfectCookID == item.id) or
(localSkillID == 'Cooking' and recipe.perfectCookID == item.id) or
(localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, item.id)) then
(localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, item.id)) then
table.insert(lineArray, Icons._SkillReq(skill, recipe.level))
local level, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe)
table.insert(lineArray, Icons._SkillReq(skill, level, false, (isAbyssal and "melvorItA:Abyssal" or nil)))
break
break
end
end
Line 598: Line 648:
end
end


--AstrologyCheck (Just a brute force for now because only two items)
--AstrologyCheck
if Shared.contains({SkillData.Astrology.stardustItemID, SkillData.Astrology.goldenStardustItemID}, item.id) then
for i, dustDrop in ipairs(SkillData.Astrology.baseRandomItemChances) do
table.insert(lineArray, Icons.Icon({SkillData.Astrology.name, type='skill'}))
if dustDrop.itemID == item.id then
table.insert(lineArray, Icons.Icon({SkillData.Astrology.name, type='skill'}))
end
end
end


Line 626: Line 678:
if Shared.contains(SkillData.Fishing.junkItemIDs, item.id) then
if Shared.contains(SkillData.Fishing.junkItemIDs, item.id) then
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Junk|Junk]]')
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Junk|Junk]]')
-- Specials
elseif GameData.getEntityByProperty(SkillData.Fishing.specialItems, 'itemID', item.id) ~= nil then
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Special|Special]]')
elseif item.id == SkillData.Fishing.lostChestItem then
elseif item.id == SkillData.Fishing.lostChestItem then
table.insert(lineArray, Icons._SkillReq(SkillData.Fishing.name, 100))
table.insert(lineArray, Icons._SkillReq(SkillData.Fishing.name, 100))
end
-- Specials
for i, specialItem in ipairs(SkillData.Fishing.specialItems) do
if GameData.getEntityByProperty(specialItem.drops, 'itemID', item.id) ~= nil then
table.insert(lineArray, Icons.Icon({'Fishing', type='skill', notext=true}) .. ' [[Fishing#Special|Special]]')
end
end
end


Line 807: Line 862:
end
end
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon.. level)
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon.. level)
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Shared.formatnum(minqty))
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Num.formatnum(minqty))
if qty ~= minqty then table.insert(rowPart, ' - '..Shared.formatnum(qty)) end
if qty ~= minqty then table.insert(rowPart, ' - '..Num.formatnum(qty)) end
local chance = weight / totalWeight * 100
local chance = weight / totalWeight * 100
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places
Line 818: Line 873:
table.insert(rowPart, '\r\n|colspan="2" ')
table.insert(rowPart, '\r\n|colspan="2" ')
else
else
local fraction = Shared.fraction(weight, totalWeight)
local fraction = Num.fraction(weight, totalWeight)
if Shared.contains(fraction, '%.') then
if Shared.contains(fraction, '%.') then
--If fraction contains decimals, something screwy happened so just show only percentage
--If fraction contains decimals, something screwy happened so just show only percentage
Line 824: Line 879:
table.insert(rowPart, '\r\n|colspan="2" ')
table.insert(rowPart, '\r\n|colspan="2" ')
else
else
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="' .. chanceStr .. '"| ' .. Shared.fraction(weight, totalWeight) .. '\r\n|')
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="' .. chanceStr .. '"| ' .. Num.fraction(weight, totalWeight) .. '\r\n|')
end
end
end
end
Line 850: Line 905:
table.insert(dropRows, {
table.insert(dropRows, {
source = Icons.Icon({iconName, type='monster'}),  
source = Icons.Icon({iconName, type='monster'}),  
level = Icons.Icon({'Monsters', img='Combat', notext=true}) .. ' Level ' .. Shared.formatnum(monsterLevel),
level = Icons.Icon({'Combat', 'Monsters', notext=true}) .. ' Level ' .. Num.formatnum(monsterLevel),
levelNum = monsterLevel,
levelNum = monsterLevel,
minqty = drop.minQty,  
minqty = drop.minQty,  
Line 877: Line 932:


-- Is the item dropped from any dungeon?
-- Is the item dropped from any dungeon?
for i, dungeon in ipairs(GameData.rawData.dungeons) do
local dungeonEntities = {
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or
['Dungeon'] = GameData.rawData.dungeons,
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then
['The Abyss'] = GameData.rawData.abyssDepths
table.insert(dropRows, {
}
source = Icons.Icon({dungeon.name, type='dungeon'}),  
for entity, dungeons in pairs(dungeonEntities) do
level = '[[Dungeon]]',
local iconType = entity == 'Dungeon' and 'dungeon' or 'combatArea'
minqty = 1,  
for i, dungeon in ipairs(dungeons) do
qty = 1,  
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or
weight = 1,  
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then
totalWeight = 1,  
table.insert(dropRows, {
expIcon = Icons.getExpansionIcon(dungeon.id)})
source = Icons.Icon({dungeon.name, type=iconType}),  
elseif dungeon.eventID ~= nil then
level = '[['..entity..']]',
-- Is the item dropped from a combat event (e.g. Impending Darkness event)?
minqty = 1,  
local event = GameData.getEntityByID('combatEvents', dungeon.eventID)
qty = 1,  
if type(event) == 'table' and type(event.itemRewardIDs) == 'table' then
weight = 1,  
for eventCycle, itemRewardID in ipairs(event.itemRewardIDs) do
totalWeight = 1,  
if item.id == itemRewardID then
expIcon = Icons.getExpansionIcon(dungeon.id)})
local sourceTxt = Icons.Icon({dungeon.name, type='dungeon'}) .. (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or ', Cycle ' .. eventCycle)
elseif dungeon.eventID ~= nil then
-- Is the item dropped from a combat event (e.g. Impending Darkness event)?
local event = GameData.getEntityByID('combatEvents', dungeon.eventID)
if type(event) == 'table' and type(event.itemRewardIDs) == 'table' then
for eventCycle, itemRewardID in ipairs(event.itemRewardIDs) do
if item.id == itemRewardID then
local sourceTxt = Icons.Icon({dungeon.name, type=iconType}) .. (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or ', Cycle ' .. eventCycle)
table.insert(dropRows, {
source = sourceTxt,
level = '[['..entity..']]',
minqty = 1,
qty = 1,
weight = 1,
totalWeight = 1})
break
end
end
end
end
end
end
 
for i, stronghold in ipairs(GameData.rawData.strongholds) do
for tier, tierData in pairs(stronghold.tiers) do
if type(tierData.rewards) == 'table' and type(tierData.rewards.items) == 'table' then
for i, reward in ipairs(tierData.rewards.items) do
if reward.id == item.id then
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = Icons.Icon({stronghold.name, type='combatArea'}),  
level = '[[Dungeon]]',
level = '[[Strongholds|'..tier..']]',
minqty = 1,  
minqty = 1,  
qty = 1,  
qty = 1,  
weight = 1,  
weight = tierData.rewards.chance,  
totalWeight = 1})
totalWeight = 100,
break
expIcon = Icons.getExpansionIcon(stronghold.id)})
end
end
end
end
Line 945: Line 1,026:
sourceTxt = Icons.Icon({thiefRow.npc, type='thieving'})
sourceTxt = Icons.Icon({thiefRow.npc, type='thieving'})
end
end
local levelNum = thiefRow.abyssalLevel or thiefRow.level
local isAbyssal = thiefRow.abyssalLevel ~= nil
table.insert(dropRows, {
table.insert(dropRows, {
source = sourceTxt,  
source = sourceTxt,
level = Icons._SkillReq("Thieving", thiefRow.level),
level = Icons._SkillReq("Thieving", levelNum, false, (isAbyssal and "melvorItA:Abyssal" or nil)),
levelNum = thiefRow.level,
levelNum = levelNum,
minqty = thiefRow.minQty,  
minqty = thiefRow.minQty,  
qty = thiefRow.maxQty,  
qty = thiefRow.maxQty,  
Line 957: Line 1,040:


-- Fishing: Junk & Specials
-- Fishing: Junk & Specials
if Shared.contains(SkillData.Fishing.junkItems, item.id) then
if Shared.contains(SkillData.Fishing.junkItemIDs, item.id) then
local fishSource = '[[Fishing#Junk|Junk]]'
local fishSource = '[[Fishing#Junk|Junk]]'
local fishType = Icons.Icon({'Fishing', type='skill'})
local fishType = Icons.Icon({'Fishing', type='skill'})
local fishTotWeight = Shared.tableCount(SkillData.Fishing.JunkItems)
local fishTotWeight = Shared.tableCount(SkillData.Fishing.junkItemIDs)
table.insert(dropRows, {
table.insert(dropRows, {
source = fishSource,  
source = fishSource,  
Line 970: Line 1,053:
totalWeight = fishTotWeight})
totalWeight = fishTotWeight})
else
else
local fishTotWeight, fishItem = 0, nil
local fishTotWeight, fishItem, realmID = {['melvorD:Melvor'] = 0, ['melvorItA:Abyssal'] = 0}, nil, nil
for i, specialItem in ipairs(SkillData.Fishing.specialItems) do
for i, specialItem in ipairs(SkillData.Fishing.specialItems) do
if specialItem.itemID == item.id then
for f, drop in ipairs(specialItem.drops) do
fishItem = specialItem
if drop.itemID == item.id then
fishItem = drop
realmID = specialItem.realmID
end
fishTotWeight[specialItem.realmID] = fishTotWeight[specialItem.realmID] + drop.weight
end
end
fishTotWeight = fishTotWeight + specialItem.weight
end
end
if fishItem ~= nil then
if fishItem ~= nil then
Line 982: Line 1,068:
table.insert(dropRows, {
table.insert(dropRows, {
source = fishSource,  
source = fishSource,  
level = Icons._SkillReq("Fishing", 1),
level = Icons._SkillReq("Fishing", 1, false, realmID),
levelNum = 1,
levelNum = 1,
minqty = fishItem.minQuantity,  
minqty = fishItem.minQuantity,  
qty = fishItem.maxQuantity,  
qty = fishItem.maxQuantity,  
weight = fishItem.weight,  
weight = fishItem.weight,  
totalWeight = fishTotWeight})
totalWeight = fishTotWeight[realmID]})
end
end
end
end
Line 1,081: Line 1,167:
local upgrade = GameData.getEntityByProperty('itemUpgrades', 'upgradedItemID', item.id)
local upgrade = GameData.getEntityByProperty('itemUpgrades', 'upgradedItemID', item.id)
if upgrade ~= nil then
if upgrade ~= nil then
local upgradeCost = {}
local upgradeCost = Common.getCostString({
for i, itemCost in ipairs(upgrade.itemCosts) do
["items"] = upgrade.itemCosts,
local costItem = Items.getItemByID(itemCost.id)
["currencies"] = upgrade.currencyCosts
if costItem ~= nil then
})
table.insert(upgradeCost, Icons.Icon({costItem.name, type='item', qty=itemCost.quantity}))
 
end
end
if type(upgrade.gpCost) == 'number' and upgrade.gpCost > 0 then
table.insert(upgradeCost, Icons.GP(upgrade.gpCost))
end
if type(upgrade.scCost) == 'number' and upgrade.scCost > 0 then
table.insert(upgradeCost, Icons.SC(upgrade.scCost))
end
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]')
table.insert(resultPart, '{| class="wikitable"\r\n|-\r\n!colspan="2"|[[Upgrading Items|Item Upgrade]]')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials\r\n|')
table.insert(resultPart, '\r\n|-\r\n!style="text-align:right;"|Materials\r\n|')
table.insert(resultPart, table.concat(upgradeCost, '<br/>'))
table.insert(resultPart, upgradeCost)
table.insert(resultPart, '\r\n|}')
table.insert(resultPart, '\r\n|}')
end
end
Line 1,260: Line 1,338:


for i, item in ipairs(itemArray) do
for i, item in ipairs(itemArray) do
local passiveDesc = item.customDescription or Constants.getModifiersText(item.modifiers, false)
local passiveDesc = item.customDescription or Modifiers.getModifiersText(item.modifiers, false, false, 10)
table.insert(resultPart, '|-\r\n')
table.insert(resultPart, '|-\r\n')
table.insert(resultPart, '! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! '..Icons.Icon({item.name, type='item', noicon=true})..'\r\n')
table.insert(resultPart, '! '..Icons.Icon({item.name, type='item', notext='true'})..'\r\n! '..Icons.Icon({item.name, type='item', noicon=true})..'\r\n')
Line 1,305: Line 1,383:
chance = chance * lootChance
chance = chance * lootChance
weight = weight * 100
weight = weight * 100
chance, weight = Shared.fractionpair(chance, weight)
chance, weight = Num.fractionpair(chance, weight)
end
end
if chance > 0 then
if chance > 0 then
Line 1,361: Line 1,439:
end
end


--[==[
--[[
-- Uncomment this block and execute 'p.test()' within the debug console
-- Uncomment this block and execute 'p.test()' within the debug console
-- to test after making changes
-- to test after making changes
Line 1,408: Line 1,486:
"Lemon",
"Lemon",
"Aranite Brush",
"Aranite Brush",
"Barrier Dust"
"Barrier Dust",
"Shadow Raven Nest",
"Void Wisp"
}
}
local checkFuncs = {
local checkFuncs = {
p.getItemSourceTables,
--p.getItemSourceTables,
--p.getCreationTable,
--p.getCreationTable,
p.getItemSources,
--p.getItemSources,
--p.getItemLootSourceTable,
--p.getItemLootSourceTable,
}
}
Line 1,436: Line 1,516:
end
end
end
end
--]==]
--]]


return p
return p