Module:Data
Documentation for this module may be created at Module:Data/doc
local p = {}
local utils = require("Module:Utils")
local constant = mw.loadJsonData("Module:Constant.json")
local data = mw.loadJsonData("Module:Data.json")
local id = mw.loadJsonData("Module:ObjectID.json")
local lootTable = mw.loadJsonData("Module:LootTable.json")
function p.createInfobox(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local image = frame.args.image
local object = data[name]
local category = utils.getCategory(name)
local str = {
image = image,
type = category and category[1] .. ', ' .. category[2],
rarity = object.rarity,
level = object.level,
mana = object.equip and (object.equip.mana and object.equip.mana[object.level]),
damage = utils.getDamage(object),
aps = '',
effects = utils.getEffects(object),
seteffects = utils.getSetEffects(object, frame),
durability = object.equip and object.equip.durability,
fullness = object.equip and object.equip.fullness,
cookable = object.canBeCooked and 'Yes',
paintable = object.canBePainted and 'Yes',
description = object.description,
value = object.value
}
if object.equip then
str.aps = object.equip.aps and object.equip.aps or ''
elseif object.trap then
str.aps = object.trap.aps and object.trap.aps or ''
end
return frame:expandTemplate{title = 'Object infobox', args = str}
end
function p.createDrops(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local object = data[name]
local str = ""
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Item !! Chance<br>(per roll) !! Chance<br>(at least 1)'
if object.loot then
if object.loot.chestLoot or object.loot.chestLootAlt then
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | Boss chest '
if object.loot.chestLoot then
local name2 = id[object.loot.chestLoot]
str = str .. '\n|- '
str = str .. '\n| colspan=3 | ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
end
if object.loot.chestLootAlt then
local name2 = id[object.loot.chestLootAlt]
str = str .. '\n|- '
str = str .. '\n| colspan=3 | ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
end
end
if object.loot.otherLoot then
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | 1 roll'
for k, v in ipairs(object.loot.otherLoot) do
local name2 = id[v.id]
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v.amount, frame)
str = str .. '\n| colspan=2 | ' .. object.loot.otherLootChance * 100 .. '%'
end
end
if object.loot.lootTable then
local lootTableObj = lootTable[object.loot.lootTable]
if utils.length(lootTableObj.guaranteedLoot) > 0 then
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | 1 roll'
for k, v in ipairs(lootTableObj.guaranteedLoot) do
local name2 = id[v.id]
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v.amount, frame)
str = str .. '\n| colspan=2 | ' .. v.chance
end
end
local roll = lootTableObj.roll
local s = 's'
if utils.length(lootTableObj.guaranteedLoot) > 0 then
if type(roll) == 'table' then
roll = roll[1] - 1 .. '-' .. roll[2] - 1
else
roll = roll - 1
if roll < 2 then s = '' end
end
else
if type(roll) == 'table' then
roll = roll[1] .. '-' .. roll[2]
else
if roll < 2 then s = '' end
end
end
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | ' .. roll .. ' roll' .. s
for k, v in ipairs(lootTableObj.loot) do
local name2 = id[v.id]
local icon = v.id == 0 and 'Nothing' or p.singleIcon(name2, v.amount, frame)
str = str .. '\n|- '
str = str .. '\n| ' .. icon
str = str .. '\n| ' .. v.chance
str = str .. '\n| ' .. v.chanceAtLeastOne
end
end
if object.loot.seasonalLoot then
for k, v in ipairs(object.loot.seasonalLoot) do
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | 1 roll (season ' .. v.season .. ')'
for k2, v2 in ipairs(v.loot) do
local name2 = id[v2.id]
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v2.amount, frame)
str = str .. '\n| colspan=2 | ' .. v2.chance .. '%'
end
end
end
end
str = str .. '\n|}'
return str
end
function p.createAcquisition(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local object = data[name]
local str = ""
if object.unpolished then
local unpolishedName = id[object.unpolished]
local unpolishedObject = data[unpolishedName]
local craft = unpolishedObject.acquisition.crafted and unpolishedObject.acquisition.crafted or unpolishedObject.acquisition.refined
str = str .. '\n=== Craft ==='
for k, v in ipairs(craft) do
local name2 = id[craft[k]]
local object2 = data[name2]
local result = utils.find(object2.usage.crafting.canCraft, "id", unpolishedObject.id)
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n| Crafting station'
str = str .. '\n| ' .. (name2 ~= 'Player' and frame:expandTemplate{title = 'Icon', args = {name2}} or 'By hand')
str = str .. '\n|-'
str = str .. '\n| Result'
str = str .. '\n| ' .. p.singleIcon(unpolishedName, result.amount, frame)
str = str .. '\n|-'
str = str .. '\n| Polished'
str = str .. '\n| ' .. p.singleIcon(name, result.amount, frame)
str = str .. '\n|-'
str = str .. '\n| Materials'
str = str .. '\n| ' .. p.icon(unpolishedObject.materials, "<br>", frame)
str = str .. '\n|}'
end
end
if object.acquisition.crafted then
local craft = object.acquisition.crafted and object.acquisition.crafted or object.acquisition.refined
str = str .. '\n=== Craft ==='
for k, v in ipairs(craft) do
local name2 = id[craft[k]]
local object2 = data[name2]
local result = utils.find(object2.usage.crafting.canCraft, "id", object.id)
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n| Crafting station'
str = str .. '\n| ' .. (name2 ~= 'Player' and frame:expandTemplate{title = 'Icon', args = {name2}} or 'By hand')
str = str .. '\n|-'
str = str .. '\n| Result'
str = str .. '\n| ' .. p.singleIcon(name, result.amount, frame)
if object.polished then
local name3 = id[object.polished]
str = str .. '\n|-'
str = str .. '\n| Polished'
str = str .. '\n| ' .. p.singleIcon(name3, result.amount, frame)
end
str = str .. '\n|-'
str = str .. '\n| Materials'
str = str .. '\n| ' .. (object.taggedMaterials and object.taggedMaterials .. '<br>' or '') .. p.icon(object.materials, '<br>', frame)
str = str .. '\n|}'
end
end
if object.acquisition.refined then
str = str .. '\n=== Refine ==='
for k, v in ipairs(object.acquisition.refined) do
local name2 = id[object.acquisition.refined[k]]
local object2 = data[name2]
local result = utils.find(object2.usage.crafting.canCraft, "id", object.id)
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n| Refiner'
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n|-'
str = str .. '\n| Result'
str = str .. '\n| ' .. p.singleIcon(name, result.amount, frame)
str = str .. '\n|-'
str = str .. '\n| Materials'
str = str .. '\n| ' .. (object.taggedMaterials and object.taggedMaterials .. '<br>' or '') .. p.icon(object.materials, "<br>", frame)
str = str .. '\n|}'
end
end
if object.acquisition.produced then
str = str .. '\n=== Produce ==='
for k, v in ipairs(object.acquisition.produced) do
local name2 = id[object.acquisition.produced[k]]
local object2 = data[name2]
local result = utils.find(object2.usage.crafting.canCraft, "id", object.id)
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n| Cattle'
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n|-'
str = str .. '\n| Produce'
str = str .. '\n| ' .. p.singleIcon(name, result.amount, frame)
str = str .. '\n|}'
end
end
if object.acquisition.combined then
str = str .. '\n=== Combine ==='
for k, v in ipairs(object.acquisition.combined) do
local name2 = id[object.acquisition.combined[k]]
local object2 = data[name2]
local result = utils.find(object2.usage.crafting.canCraft, "id", object.id)
if object2.usage.crafting.requiresNearbyObject > 0 then
str = str .. '\nNote: Can only be combined near the ' .. id[object2.usage.crafting.requiresNearbyObject] .. '.'
end
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n| Casting item'
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n|-'
str = str .. '\n| Result'
str = str .. '\n| ' .. p.singleIcon(name, result.amount, frame)
str = str .. '\n|-'
str = str .. '\n| Materials'
str = str .. '\n| ' .. p.icon(object.materials, "<br>", frame)
str = str .. '\n|}'
end
end
if object.acquisition.fished then
str = str .. '\n=== Fishing ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Water !! Location !! Type !! Amount !! Chance'
for k, v in ipairs(object.acquisition.fished) do
local fish = constant.Acquisition.Fishing[v]
local loot = utils.find(lootTable[v].loot, "id", object.id)
local amount = type(loot.amount) == 'table' and loot.amount[1] .. '-' .. loot.amount[2] or loot.amount
str = str .. '\n|- '
str = str .. '\n| ' .. fish.water
str = str .. '\n| ' .. fish.location
str = str .. '\n| ' .. fish.type
str = str .. '\n| ' .. amount
str = str .. '\n| ' .. loot.chance
end
str = str .. '\n|}'
end
if object.acquisition.container or object.acquisition.containerTable then
str = str .. '\n=== Container ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Item !! Amount !! Chance'
if object.acquisition.container then
for k, v in ipairs(object.acquisition.container) do
local name2 = id[object.acquisition.container[k]]
local object2 = data[name2]
local result = utils.find(object2.usage.container, "id", object.id)
local amount = type(result.amount) == 'table' and result.amount[1] .. '-' .. result.amount[2] or result.amount
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| ' .. amount
str = str .. '\n| ' .. result.chance .. '%'
end
end
if object.acquisition.containerTable then
for k, v in ipairs(object.acquisition.containerTable) do
local name2 = id[object.acquisition.containerTable[k]]
local object2 = data[name2]
local loot = utils.find(lootTable[object2.usage.containerTable].loot, "id", object.id)
local amount = type(loot.amount) == 'table' and loot.amount[1] .. '-' .. loot.amount[2] or loot.amount
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| ' .. amount
str = str .. '\n| ' .. loot.chance
end
end
str = str .. '\n|}'
end
if object.acquisition.shop then
str = str .. '\n=== Shop ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Merchant !! Stock !! Price !! Requirement'
for k, v in ipairs(object.acquisition.shop) do
local name2 = id[object.acquisition.shop[k]]
local object2 = data[name2]
local result = utils.find(object2.shop, "id", object.id)
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| ' .. (result.amount > 0 and result.amount or 'No limit')
str = str .. '\n| ' .. frame:expandTemplate{title = 'Ancient coin', args = {object.buy}}
str = str .. '\n| ' .. (result.requirement and result.requirement or 'None')
end
str = str .. '\n|}'
end
if object.acquisition.damage then
str = str .. '\n=== Boulder ==='
str = str .. '\nCan be mined with stationary drill from '
for k, v in ipairs(object.acquisition.damage) do
local name2 = id[object.acquisition.damage[k]]
local object2 = data[name2]
str = str .. frame:expandTemplate{title = 'Icon', args = {name2}} .. ', '
end
str = str:sub(1, -3) .. '.'
end
-- if object.acquisition.inventory or object.acquisition.inventoryTable then
if object.acquisition.inventory then
str = str .. '\n=== Inventory ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Scene !! Container'
if object.acquisition.inventory then
for k, v in ipairs(object.acquisition.inventory) do
local name2 = id[v.id]
-- local object2 = data[name2]
-- if object2.loot and object2.loot.inventory then
-- local result = utils.find(object2.loot.inventory, "id", object.id)
-- amount = type(result.amount) == 'table' and result.amount[1] .. '-' .. result.amount[2] or result.amount
-- chance = result.chance .. '%'
-- end
str = str .. '\n|- '
str = str .. '\n| ' .. v.scene
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
end
end
-- if object.acquisition.inventoryTable then
-- for k, v in ipairs(object.acquisition.inventoryTable) do
-- local name2 = id[object.acquisition.inventoryTable[k]]
-- local object2 = data[name2]
-- local amount = '?'
-- local chance = '?'
-- if object2.loot and object2.loot.inventoryTable then
-- local loot = utils.find(lootTable[object2.loot.inventoryTable].loot, "id", object.id)
-- amount = type(loot.amount) == 'table' and loot.amount[1] .. '-' .. loot.amount[2] or loot.amount
-- chance = loot.chance
-- end
-- str = str .. '\n|- '
-- str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
-- str = str .. '\n| ' .. amount
-- str = str .. '\n| ' .. chance
-- end
-- end
str = str .. '\n|}'
end
if object.acquisition.lock then
str = str .. '\n=== Locked chest ==='
str = str .. '\n<div class="smallbox-b-grid">'
for k, v in ipairs(object.acquisition.lock) do
local name2 = id[v]
local object2 = data[name2]
str = str .. '<div><div class="smallbox-b-image ' .. object2.rarity .. '">[[File:' .. name2 .. '.png|link=' .. name2 .. '|' .. name2 .. ']]</div><div class="smallbox-b-text">[[' .. name2 .. ']]</div></div>'
end
str = str .. '</div>'
end
if object.acquisition.arch == 1 then
str = str .. '\n=== Archaeologist ==='
str = str .. '\nCan be mined from any walls while having [[Archaeologist]] skill leveled. Higher level will increase chance of drop.'
end
if object.acquisition.drop then
str = str .. '\n=== Drop ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Object !! Type !! Amount !! Rolls !! Chance<br>(per roll) !! Chance<br>(at least 1)'
for k, v in ipairs(object.acquisition.drop) do
local name2 = id[object.acquisition.drop[k]]
local object2 = data[name2]
if object2 and object2.loot then
if object2.loot.chestLoot == object.id or object2.loot.chestLootAlt == object.id then
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| Boss chest'
str = str .. '\n| 1'
str = str .. '\n| 1'
str = str .. '\n| 100%'
str = str .. '\n| 100%'
end
if object2.loot.otherLoot then
local result = utils.find(object2.loot.otherLoot, "id", object.id)
if result then
local amount = type(result.amount) == 'table' and result.amount[1] .. '-' .. result.amount[2] or result.amount
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| Loot'
str = str .. '\n| ' .. amount
str = str .. '\n| 1'
str = str .. '\n| ' .. object2.loot.otherLootChance * 100 .. '%'
str = str .. '\n| ' .. object2.loot.otherLootChance * 100 .. '%'
end
end
if object2.loot.lootTable then
local lootTableObj = lootTable[object2.loot.lootTable]
local loot = utils.find(lootTableObj.guaranteedLoot, "id", object.id)
if loot then
local amount = type(loot.amount) == 'table' and loot.amount[1] .. '-' .. loot.amount[2] or loot.amount
local chance = loot.chance
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| Random loot - one guaranteed drop'
str = str .. '\n| ' .. amount
str = str .. '\n| 1'
str = str .. '\n| ' .. chance
str = str .. '\n| ' .. chance
end
loot = utils.find(lootTableObj.loot, "id", object.id)
if loot then
local amount = type(loot.amount) == 'table' and loot.amount[1] .. '-' .. loot.amount[2] or loot.amount
local roll = lootTableObj.roll
if utils.length(lootTableObj.guaranteedLoot) > 0 then
if type(roll) == 'table' then
roll = roll[1] - 1 .. '-' .. roll[2] - 1
else
roll = roll - 1
end
else
if type(roll) == 'table' then
roll = roll[1] .. '-' .. roll[2]
end
end
local chance = loot.chance
local chanceOne = loot.chanceAtLeastOne
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| Random loot'
str = str .. '\n| ' .. amount
str = str .. '\n| ' .. roll
str = str .. '\n| ' .. chance
str = str .. '\n| ' .. chanceOne
end
end
if object2.loot.seasonalLoot then
for k2, v2 in ipairs(object2.loot.seasonalLoot) do
local result = utils.find(v2.loot, "id", object.id)
if result then
local amount = type(result.amount) == 'table' and result.amount[1] .. '-' .. result.amount[2] or result.amount
local chance = result.chance .. "%"
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| Seasonal loot - season ' .. v2.season
str = str .. '\n| ' .. amount
str = str .. '\n| 1'
str = str .. '\n| ' .. chance
str = str .. '\n| ' .. chance
end
end
end
end
end
str = str .. '\n|}'
end
if object.acquisition.battleArenaTable then
local battleArenaTable = lootTable[object.acquisition.battleArenaTable]
local loot = utils.find(battleArenaTable.loot, "id", object.id)
local amount = type(loot.amount) == 'table' and loot.amount[1] .. '-' .. loot.amount[2] or loot.amount
local roll = battleArenaTable.roll
local chance = loot.chance
local chanceOne = loot.chanceAtLeastOne
str = str .. '\n=== Ancient Battle Arena ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Type !! Amount !! Rolls !! Chance<br>(per roll) !! Chance<br>(at least 1)'
str = str .. '\n|- '
str = str .. '\n| Random loot'
str = str .. '\n| ' .. amount
str = str .. '\n| ' .. roll
str = str .. '\n| ' .. chance
str = str .. '\n| ' .. chanceOne
str = str .. '\n|}'
end
return str
end
function p.createUsage(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local object = data[name]
local str = ""
if object.use then
if object.use ~= 'Combine the materials' and object.use ~= 'Hatch egg' and object.use ~= 'Open container' then
str = str .. '\n=== Other ==='
str = str .. '\n' .. object.use
end
end
if object.usage.crafting then
str = str .. '\n=== ' .. object.usage.crafting.type .. ' ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Result !! Materials'
for k, v in ipairs(object.usage.crafting.canCraft) do
local name2 = id[v.id]
local object2 = data[name2]
local materials = (object2.taggedMaterials and object2.taggedMaterials .. ' ' or '') .. p.icon(object2.materials, " " , frame)
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v.amount, frame)
str = str .. '\n| ' .. materials
end
if utils.length(object.usage.crafting.includes) > 0 then
str = str .. '\n|- '
str = str .. '\n| colspan=2 | Also includes all crafting recipes from ' .. p.iconIdOnly(object.usage.crafting.includes , frame)
end
str = str .. '\n|}'
end
if object.usage.craftingMaterial then
str = str .. '\n=== Crafting material ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Crafting station !! Result !! Materials'
for k, v in ipairs(object.usage.craftingMaterial) do
local name2 = id[v]
local object2 = data[name2]
for k2, v2 in ipairs(object2.usage.crafting.canCraft) do
local name3 = id[v2.id]
local object3 = data[name3]
local find = utils.find(object3.materials, "id", object.id)
if find then
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| ' .. p.singleIcon(name3, v2.amount, frame)
str = str .. '\n| ' .. (object3.taggedMaterials and object3.taggedMaterials .. ' ' or '') .. p.icon(object3.materials, " " , frame)
end
end
end
str = str .. '\n|}'
end
if object.usage.refining then
str = str .. '\n=== Refining material ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Refiner !! Result !! Materials'
for k, v in ipairs(object.usage.refining) do
local name2 = id[v]
local object2 = data[name2]
for k2, v2 in ipairs(object2.usage.crafting.canCraft) do
local name3 = id[v2.id]
local object3 = data[name3]
local find = utils.find(object3.materials, "id", object.id)
if find then
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| ' .. p.singleIcon(name3, v2.amount, frame)
str = str .. '\n| ' .. (object3.taggedMaterials and object3.taggedMaterials .. ' ' or '') .. p.icon(object3.materials, " " , frame)
end
end
end
str = str .. '\n|}'
end
if object.usage.combining then
str = str .. '\n=== Combining material ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Combiner !! Result !! Materials'
for k, v in ipairs(object.usage.combining) do
local name2 = id[v]
local object2 = data[name2]
for k2, v2 in ipairs(object2.usage.crafting.canCraft) do
local name3 = id[v2.id]
local object3 = data[name3]
local find = utils.find(object3.materials, "id", object.id)
if find then
str = str .. '\n|- '
str = str .. '\n| ' .. frame:expandTemplate{title = 'Icon', args = {name2}}
str = str .. '\n| ' .. p.singleIcon(name3, v2.amount, frame)
str = str .. '\n| ' .. p.icon(object3.materials, " " , frame)
end
end
end
str = str .. '\n|}'
end
if object.usage.container then
str = str .. '\n=== ' .. object.use .. ' ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Result !! Chance'
for k, v in ipairs(object.usage.container) do
local name2 = id[v.id]
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v.amount, frame)
str = str .. '\n| ' .. v.chance .. '%'
end
str = str .. '\n|}'
end
if object.usage.containerTable then
str = str .. '\n=== ' .. object.use .. ' ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Item !! Chance<br>(per roll) !! Chance<br>(at least 1)'
local lootTableObj = lootTable[object.usage.containerTable]
if utils.length(lootTableObj.guaranteedLoot) > 0 then
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | 1 roll '
for k, v in ipairs(lootTableObj.guaranteedLoot) do
local name2 = id[v.id]
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v.amount, frame)
str = str .. '\n| colspan=2 | ' .. v.chance
end
end
local roll = lootTableObj.roll
local s = 's'
if utils.length(lootTableObj.guaranteedLoot) > 0 then
if type(roll) == 'table' then
roll = roll[1] - 1 .. '-' .. roll[2] - 1
else
roll = roll - 1
if roll < 2 then s = '' end
end
else
if type(roll) == 'table' then
roll = roll[1] .. '-' .. roll[2]
else
if roll < 2 then s = '' end
end
end
str = str .. '\n|- class=subheader'
str = str .. '\n! colspan=3 | ' .. roll .. ' roll' .. s
for k, v in ipairs(lootTableObj.loot) do
local name2 = id[v.id]
str = str .. '\n|- '
str = str .. '\n| ' .. p.singleIcon(name2, v.amount, frame)
str = str .. '\n| ' .. v.chance
str = str .. '\n| ' .. v.chanceAtLeastOne
end
str = str .. '\n|}'
end
if object.usage.upgrade then
str = str .. '\n=== Upgrade material ==='
str = str .. '\n{| class="table table-dark" style="width:auto"'
str = str .. '\n! Level !! Materials'
for k, v in ipairs(object.usage.upgrade) do
local upgrade = constant.UpgradeCost[v]
str = str .. '\n|- '
str = str .. '\n| ' .. v
str = str .. '\n| ' .. p.icon(upgrade, " " , frame)
end
str = str .. '\n|}'
end
if object.conditionsWhenCooked then
str = str .. '\n=== Cooking ingredient ===\n'
str = str .. p.createCookingEffect(object)
end
return str
end
function p.createStats(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local object = data[name]
if object.pet then
return p.createPetStats(object)
end
local level = object.level
local str = ''
if object.type == 'PlaceablePrefab' then
str = str .. '{| class="table table-dark" style="width:auto"\n'
str = str .. '|-\n'
str = str .. '! Health\n'
str = str .. '| ' .. object.health .. '\n'
str = str .. '|-\n'
str = str .. '! Mining damage reduction\n'
str = str .. '| ' .. object.damageReduction .. '\n'
str = str .. '|-\n'
str = str .. '! Mining exp. gain threshold\n'
str = str .. '| ' .. object.damageReduction + 12 .. '+ mining damage\n'
-- local threshold = (object.health / 12) + object.damageReduction
-- str = str .. '|-\n'
-- str = str .. '! Threshold for sharp sound effect\n'
-- str = str .. '| ' .. object.type .. '\n'
str = str .. '|}'
return str
end
str = str .. '<div class="row">\n'
str = str .. '<div class="col-6"><div class="darkbox grid-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Base level ' .. object.level .. '</div>\n'
str = str .. p.statsText(object, object.level, frame) .. '\n'
str = str .. '</div></div><div class="col-6"><div class="darkbox grid-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Max level ' .. constant.MaxLevel .. '</div>\n'
str = str .. p.statsText(object, constant.MaxLevel, frame) .. '\n'
str = str .. '</div></div>'
local max = ''
if level < constant.MaxLevel then
for k, v in ipairs(constant.MaxUpgradeCost[level]) do
max = max .. frame:expandTemplate{title = 'Icon', args = {id[v.id], v.amount}} .. ' '
end
end
str = str .. '<div class="col-12"><div class="darkbox mt-4">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Max upgrade cost</div>\n'
str = str .. max
str = str .. '</div></div></div>'
return str
end
function p.statsText(object, level, frame)
local currentLevel = level and level or obj.level
local str = ''
str = str .. (object.equip and (object.equip.mana and '<span style="color:rgb(53 164 183)">Mana cost: ' .. object.equip.mana[currentLevel] .. '</span><br>' or ''))
local damage = utils.getDamage(object, currentLevel)
str = str .. (damage ~= '' and damage .. '<br>' or '')
str = str .. (object.equip.aps and object.equip.aps .. ' attacks per second<hr>' or '')
local effects = utils.getEffects(object, currentLevel)
str = str .. (effects ~= '' and effects .. '<hr>' or '')
local setEffects = utils.getSetEffects(object, frame)
str = str .. (setEffects ~= '' and setEffects .. '<hr>' or '')
str = str:sub(1, -5)
return str
end
function p.createPetStats(object)
local str = ''
str = str .. '<div class="row">\n'
str = str .. '<div class="col-6"><div class="darkbox grid-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Base level 1</div>\n'
str = str .. utils.getDamage(object) .. '<hr>'
str = str .. utils.getEffects(object)
str = str .. '</div></div><div class="col-6"><div class="darkbox grid-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Max level 10</div>\n'
str = str .. utils.getDamage(object, constant.PetMaxLevel) .. '<hr>'
str = str .. utils.getEffects(object)
str = str .. '</div></div></div>'
return str
end
function p.createCookingEffect(object)
local str = ''
str = str .. '<div class="row">\n'
str = str .. '<div class="col-12 col-md-4"><div class="darkbox checkerboard-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Regular</div>\n'
str = str .. utils.concat(object.conditionsWhenCooked.regular, '<br>') .. '\n'
str = str .. '</div></div><div class="col-12 col-md-4 mt-3 mt-md-0"><div class="darkbox checkerboard-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Rare</div>\n'
str = str .. utils.concat(object.conditionsWhenCooked.rare, '<br>') .. '\n'
str = str .. '</div></div><div class="col-12 col-md-4 mt-3 mt-md-0"><div class="darkbox checkerboard-pattern">\n'
str = str .. '<div class="text-center mb-3 h5" style="font-family:Mitr">Epic</div>\n'
str = str .. utils.concat(object.conditionsWhenCooked.epic, '<br>') .. '\n'
str = str .. '</div></div></div>'
return str
end
function p.createShop(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local object = data[name]
local str = ''
if object.shop then
str = str .. '{| class="table table-dark sortable" style="width:auto"'
str = str .. '\n! Icon !! Name !! Stock !! Price !! Requirement'
for k, v in ipairs(object.shop) do
local name = id[v.id]
local item = data[name]
str = str .. '\n|-'
str = str .. '\n| align=center | [[File:' .. name .. '.png|link=' .. name .. '|' .. name .. ']]'
str = str .. '\n| [[' .. name .. ']]'
str = str .. '\n| ' .. (v.amount > 0 and v.amount or 'No limit')
str = str .. '\n| ' .. frame:expandTemplate{title = 'Ancient coin', args = {item.buy}}
str = str .. '\n| ' .. v.requirement
end
str = str .. '\n|}'
end
return str
end
function p.createPetSkills(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local object = data[name]
local str = ''
if object.pet then
local pets = mw.loadJsonData("Module:Pets.json")
local type = 't' .. object.pet.type
str = str .. '{| class="table table-dark sortable" style="width:auto"\n'
str = str .. '! Icon !! Name !! Effects\n'
for k, v in ipairs(object.pet.skills) do
local petSkill = pets['i' .. v][type]
local iconName = petSkill.name
if type == 't0' then
iconName = petSkill.name .. ' (melee)'
elseif type == 't1' then
iconName = petSkill.name .. ' (range)'
end
str = str .. '|-\n'
str = str .. '| align=center | [[File:' .. iconName .. '.png|' .. petSkill.name .. ']]\n'
str = str .. '| ' .. petSkill.name .. '\n'
str = str .. '| ' .. (type == 't2' and 'Buffs owner with: ' or '') .. utils.getCondition(petSkill.id, petSkill.value) .. '\n'
end
str = str .. '|}'
end
return str
end
function p.createNavbox(frame)
local name = frame.args.name
if name == nil or name == "" then name = mw.title.getCurrentTitle().subpageText end
local navbox = ''
local type = ''
local category = utils.getCategory(name)
if category then
if category[1] == 'Boss' then
if category[2] == 'BossCreature' then
navbox = 'Character'
elseif category[2] == 'Scanner' then
navbox = 'Item'
type = 'Material'
elseif category[2] == 'SummoningItem' then
navbox = 'Item'
type = 'Material'
end
elseif category[1] == 'Creature' then
navbox = 'Character'
elseif category[1] == 'Equipment' then
navbox = 'Equipment'
if category[2] == 'Melee weapon' or category[2] == 'Range weapon' or category[2] == 'Magic weapon' then
type = 'Weapon'
elseif category[2] == 'Helm' or category[2] == 'Breast armor' or category[2] == 'Pants armor' then
type = 'Armor'
elseif category[2] == 'Tool' or category[2] == 'Paint brush' then
type = 'Tool'
else
type = 'Accessory'
end
elseif category[1] == 'Building' then
navbox = 'Item'
type = 'Building'
elseif category[1] == 'Consumable' then
navbox = 'Item'
type = 'Consumable'
elseif category[1] == 'Environment' then
navbox = 'Item'
type = 'Environment'
elseif category[1] == 'Material' then
navbox = 'Item'
type = 'Material'
elseif category[1] == 'Music' then
navbox = 'Item'
type = 'Music'
elseif category[1] == 'Other' then
navbox = 'Item'
type = 'Material'
elseif category[1] == 'Seasonal' then
navbox = 'Item'
elseif category[1] == 'Technology' then
navbox = 'Item'
type = 'Technology'
elseif category[1] == 'Valuables' then
navbox = 'Item'
type = 'Valuables'
end
return frame:expandTemplate{title = navbox .. ' navbox', args = {type}}
end
end
function p.singleIcon(name, amount, frame)
if type(amount) == 'table' then
amount = amount[1] .. '-' .. amount[2]
else
amount = amount > 1 and amount or ""
end
return frame:expandTemplate{title = 'Icon', args = {name, amount}}
end
function p.icon(t, separator, frame)
local str = ""
separator = separator and separator or " "
local length = -1 - #separator
if t ~= nil then
for k, v in ipairs(t) do
local name = id[v.id]
local amount = v.amount
if type(amount) == 'table' then
amount = amount[1] .. '-' .. amount[2]
else
amount = amount > 1 and amount or ""
end
str = str .. frame:expandTemplate{title = 'Icon', args = {name, amount}} .. separator
end
str = str:sub(1, length)
end
return str
end
function p.iconIdOnly(t, frame)
local str = ""
if t ~= nil then
for k, v in ipairs(t) do
local name = id[v]
str = str .. frame:expandTemplate{title = 'Icon', args = {name}} .. ' '
end
str = str:sub(1, -2)
end
return str
end
return p