Module:CombatAreas/AreaTables: Difference between revisions
From Melvor Idle
(removed aurora related functions) |
(Update for v1.1) |
||
Line 2: | Line 2: | ||
local p = {} | local p = {} | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local GameData = require('Module:GameData') | |||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Monsters = require('Module:Monsters') | local Monsters = require('Module:Monsters') | ||
local | local Areas = require('Module:CombatAreas') | ||
function p.getLowHighLevels(idList) | function p.getLowHighLevels(idList) | ||
local lowLevel = 1000000 | local lowLevel = 1000000 | ||
local highLevel = 0 | local highLevel = 0 | ||
for i, monID in | for i, monID in ipairs(idList) do | ||
local monster = Monsters.getMonsterByID(monID) | local monster = Monsters.getMonsterByID(monID) | ||
local cmbLevel = Monsters._getMonsterCombatLevel(monster) | local cmbLevel = Monsters._getMonsterCombatLevel(monster) | ||
Line 30: | Line 28: | ||
result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Lowest Monster Level!!Highest Monster Level' | result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Lowest Monster Level!!Highest Monster Level' | ||
local areas = p.sortByOrderTable(GameData.rawData.combatAreas, GameData.rawData.combatAreaDisplayOrder) | |||
for i, area in ipairs(areas) do | |||
result = result..'\r\n|-' | result = result..'\r\n|-' | ||
result = result..'\r\n|'..Icons.Icon({area.name, type='combat', size='50', notext=true}) | result = result..'\r\n|'..Icons.Icon({area.name, type='combat', size='50', notext=true}) | ||
result = result..'||'..Icons.Icon({area.name, type='combat', noicon=true}) | result = result..'||'..Icons.Icon({area.name, type='combat', noicon=true}) | ||
result = result..'||data-sort-value="'..area.difficulty[1]..'"|'..Areas._getAreaStat(area, 'difficulty') | |||
local lowLvl, highLvl = p.getLowHighLevels(area.monsterIDs) | |||
result = result..'||data-sort-value="'..area.difficulty[1]..'"|'.. | |||
local lowLvl, highLvl = p.getLowHighLevels(area. | |||
result = result..'||'..lowLvl..'||'..highLvl | result = result..'||'..lowLvl..'||'..highLvl | ||
end | end | ||
Line 52: | Line 47: | ||
result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Highest Monster Level!!Requirements!!Area Effect' | result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Highest Monster Level!!Requirements!!Area Effect' | ||
local areas = p.sortByOrderTable(GameData.rawData.slayerAreas, GameData.rawData.slayerAreaDisplayOrder) | |||
for i, area in ipairs(areas) do | |||
result = result..'\r\n|-' | result = result..'\r\n|-' | ||
result = result..'\r\n|'..Icons.Icon({area.name, type='slayer', size='50', notext=true}) | result = result..'\r\n|'..Icons.Icon({area.name, type='slayer', size='50', notext=true}) | ||
result = result..'||'..Icons.Icon({area.name, type='slayer', noicon=true}) | result = result..'||'..Icons.Icon({area.name, type='slayer', noicon=true}) | ||
result = result..'||data-sort-value="'..area.difficulty[1]..'"|'..Areas._getAreaStat(area, 'difficulty') | |||
local lowLvl, highLvl = p.getLowHighLevels(area.monsterIDs) | |||
result = result..'||data-sort-value="'..area.difficulty[1]..'"|'.. | |||
local lowLvl, highLvl = p.getLowHighLevels(area. | |||
result = result..'||'..highLvl | result = result..'||'..highLvl | ||
result = result..'||'.. | result = result..'||'..Areas._getAreaRequirements(area) | ||
result = result..'|| '.. | result = result..'|| '..Areas._getAreaStat(area, 'areaEffectDesc') | ||
end | end | ||
Line 83: | Line 75: | ||
-- GP reward | -- GP reward | ||
if area. | if area.eventID == nil then | ||
local bossMonster = Monsters.getMonsterByID(area. | local bossMonster = Monsters.getMonsterByID(area.monsterIDs[Shared.tableCount(area.monsterIDs)]) | ||
local | local gp = bossMonster.gpDrops | ||
if gp.min > 0 and gp.max > 0 then | |||
if gp.min == gp.max then | |||
if | table.insert(rewardList, chr .. Icons.GP(gp.min)) | ||
table.insert(rewardList, chr .. Icons.GP( | |||
else | else | ||
table.insert(rewardList, chr .. Icons.GP( | table.insert(rewardList, chr .. Icons.GP(gp.min, gp.max)) | ||
end | end | ||
end | end | ||
Line 97: | Line 88: | ||
-- Item rewards | -- Item rewards | ||
if type(area. | local itemLists = {} | ||
for i, rewardID in ipairs( | if type(area.rewardItemIDs) == 'table' then | ||
table.insert(itemLists, area.rewardItemIDs) | |||
end | |||
if area.eventID ~= nil then | |||
local event = GameData.getEntityByID('combatEvents', area.eventID) | |||
if event ~= nil and type(event.itemRewardIDs) == 'table' then | |||
table.insert(itemLists, event.itemRewardIDs) | |||
end | |||
end | |||
for i, itemList in ipairs(itemLists) do | |||
for j, rewardID in ipairs(itemList) do | |||
local rewardItem = Items.getItemByID(rewardID) | local rewardItem = Items.getItemByID(rewardID) | ||
if rewardItem == nil then | if rewardItem == nil then | ||
table.insert(rewardList, chr .. 'Unknown item (ID ' .. | table.insert(rewardList, chr .. 'Unknown item (ID ' .. rewardID .. ')[[Category:Pages with script errors]]') | ||
else | else | ||
table.insert(rewardList, chr .. Icons.Icon({rewardItem.name, type='item', qty=1})) | table.insert(rewardList, chr .. Icons.Icon({rewardItem.name, type='item', qty=1})) | ||
end | end | ||
end | end | ||
end | end | ||
Line 126: | Line 119: | ||
local areaName = frame.args ~= nil and frame.args[1] or frame | local areaName = frame.args ~= nil and frame.args[1] or frame | ||
local asList = frame.args ~= nil and frame.args[2] or true | local asList = frame.args ~= nil and frame.args[2] or true | ||
local area = | local area = Areas.getArea(areaName) | ||
if area == nil then | if area == nil then | ||
return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]' | return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]' | ||
Line 143: | Line 136: | ||
result = result..'\r\n!colspan="2"|Dungeon!!Difficulty!!Monsters!!Boss Level!!Reward(s)!!Boss Pet' | result = result..'\r\n!colspan="2"|Dungeon!!Difficulty!!Monsters!!Boss Level!!Reward(s)!!Boss Pet' | ||
for i, | local areas = p.sortByOrderTable(GameData.rawData.dungeons, GameData.rawData.dungeonDisplayOrder) | ||
local | for i, dung in ipairs(areas) do | ||
local monsterCount = Shared.tableCount(dung.monsters) | |||
local boss = Monsters.getMonsterByID(dung.monsters[monsterCount]) | |||
result = result..'\r\n|-' | result = result..'\r\n|-' | ||
result = result..'\r\n|data-sort-value="'..dung.name..'"|'..Icons.Icon({dung.name, type='dungeon', size='50', notext=true}) | result = result..'\r\n|data-sort-value="'..dung.name..'"|'..Icons.Icon({dung.name, type='dungeon', size='50', notext=true}) | ||
result = result..'||'..Icons.Icon({dung.name, type='dungeon', noicon=true}) | result = result..'||'..Icons.Icon({dung.name, type='dungeon', noicon=true}) | ||
result = result..'||data-sort-value="'..dung.difficulty[1]..'"|'.. | result = result..'||data-sort-value="'..dung.difficulty[1]..'"|'..Areas._getAreaStat(dung, 'difficulty') | ||
result = result..'||'.. | result = result..'||'..monsterCount | ||
result = result..'||'..Shared.formatnum(Monsters._getMonsterCombatLevel(boss)) | result = result..'||'..Shared.formatnum(Monsters._getMonsterCombatLevel(boss)) | ||
result = result..'||'..p._getDungeonRewards(dung, false) | result = result..'||'..p._getDungeonRewards(dung, false) | ||
if dung. | if dung.pet ~= nil then | ||
local pet = | local pet = GameData.getEntityByID('pets', dung.pet.petID) | ||
result = result..'||data-sort-value="'..pet.name..'"|'..Icons.Icon({pet.name, type='pet'}) | if pet ~= nil then | ||
result = result..'||data-sort-value="'..pet.name..'"|'..Icons.Icon({pet.name, type='pet'}) | |||
end | |||
else | else | ||
result = result..'|| ' | result = result..'|| ' |
Revision as of 15:51, 22 October 2022
Documentation for this module may be created at Module:CombatAreas/AreaTables/doc
--Splitting this out so I can make Module:Monsters calls (Monsters calls CombatAreas, so this prevents a loop)
local p = {}
local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local GameData = require('Module:GameData')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Monsters = require('Module:Monsters')
local Areas = require('Module:CombatAreas')
function p.getLowHighLevels(idList)
local lowLevel = 1000000
local highLevel = 0
for i, monID in ipairs(idList) do
local monster = Monsters.getMonsterByID(monID)
local cmbLevel = Monsters._getMonsterCombatLevel(monster)
if cmbLevel < lowLevel then lowLevel = cmbLevel end
if cmbLevel > highLevel then highLevel = cmbLevel end
end
return lowLevel, highLevel
end
function p.getCombatAreaTable()
local result = '{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Lowest Monster Level!!Highest Monster Level'
local areas = p.sortByOrderTable(GameData.rawData.combatAreas, GameData.rawData.combatAreaDisplayOrder)
for i, area in ipairs(areas) do
result = result..'\r\n|-'
result = result..'\r\n|'..Icons.Icon({area.name, type='combat', size='50', notext=true})
result = result..'||'..Icons.Icon({area.name, type='combat', noicon=true})
result = result..'||data-sort-value="'..area.difficulty[1]..'"|'..Areas._getAreaStat(area, 'difficulty')
local lowLvl, highLvl = p.getLowHighLevels(area.monsterIDs)
result = result..'||'..lowLvl..'||'..highLvl
end
result = result..'\r\n|}'
return result
end
function p.getSlayerAreaTable()
local result = '{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Highest Monster Level!!Requirements!!Area Effect'
local areas = p.sortByOrderTable(GameData.rawData.slayerAreas, GameData.rawData.slayerAreaDisplayOrder)
for i, area in ipairs(areas) do
result = result..'\r\n|-'
result = result..'\r\n|'..Icons.Icon({area.name, type='slayer', size='50', notext=true})
result = result..'||'..Icons.Icon({area.name, type='slayer', noicon=true})
result = result..'||data-sort-value="'..area.difficulty[1]..'"|'..Areas._getAreaStat(area, 'difficulty')
local lowLvl, highLvl = p.getLowHighLevels(area.monsterIDs)
result = result..'||'..highLvl
result = result..'||'..Areas._getAreaRequirements(area)
result = result..'|| '..Areas._getAreaStat(area, 'areaEffectDesc')
end
result = result..'\r\n|}'
return result
end
function p._getDungeonRewards(area, asList)
if asList == nil then
asList = true
elseif type(asList) == 'string' then
asList = asList.upper ~= 'FALSE'
end
local chr = asList and '* ' or ''
local rewardList = {}
-- GP reward
if area.eventID == nil then
local bossMonster = Monsters.getMonsterByID(area.monsterIDs[Shared.tableCount(area.monsterIDs)])
local gp = bossMonster.gpDrops
if gp.min > 0 and gp.max > 0 then
if gp.min == gp.max then
table.insert(rewardList, chr .. Icons.GP(gp.min))
else
table.insert(rewardList, chr .. Icons.GP(gp.min, gp.max))
end
end
end
-- Item rewards
local itemLists = {}
if type(area.rewardItemIDs) == 'table' then
table.insert(itemLists, area.rewardItemIDs)
end
if area.eventID ~= nil then
local event = GameData.getEntityByID('combatEvents', area.eventID)
if event ~= nil and type(event.itemRewardIDs) == 'table' then
table.insert(itemLists, event.itemRewardIDs)
end
end
for i, itemList in ipairs(itemLists) do
for j, rewardID in ipairs(itemList) do
local rewardItem = Items.getItemByID(rewardID)
if rewardItem == nil then
table.insert(rewardList, chr .. 'Unknown item (ID ' .. rewardID .. ')[[Category:Pages with script errors]]')
else
table.insert(rewardList, chr .. Icons.Icon({rewardItem.name, type='item', qty=1}))
end
end
end
if asList then
return table.concat(rewardList, '\r\n')
else
return table.concat(rewardList, '<br/>')
end
end
function p.getDungeonRewards(frame)
local areaName = frame.args ~= nil and frame.args[1] or frame
local asList = frame.args ~= nil and frame.args[2] or true
local area = Areas.getArea(areaName)
if area == nil then
return "ERROR: Could not find an area named "..areaName..'[[Category:Pages with script errors]]'
end
if area.type == 'dungeon' then
return p._getDungeonRewards(area, asList)
else
return "ERROR: "..areaName.." is not a dungeon[[Category:Pages with script errors]]"
end
end
function p.getDungeonTable(frame)
local result = '{| class="wikitable sortable stickyHeader"'
result = result..'\r\n|-class="headerRow-0"'
result = result..'\r\n!colspan="2"|Dungeon!!Difficulty!!Monsters!!Boss Level!!Reward(s)!!Boss Pet'
local areas = p.sortByOrderTable(GameData.rawData.dungeons, GameData.rawData.dungeonDisplayOrder)
for i, dung in ipairs(areas) do
local monsterCount = Shared.tableCount(dung.monsters)
local boss = Monsters.getMonsterByID(dung.monsters[monsterCount])
result = result..'\r\n|-'
result = result..'\r\n|data-sort-value="'..dung.name..'"|'..Icons.Icon({dung.name, type='dungeon', size='50', notext=true})
result = result..'||'..Icons.Icon({dung.name, type='dungeon', noicon=true})
result = result..'||data-sort-value="'..dung.difficulty[1]..'"|'..Areas._getAreaStat(dung, 'difficulty')
result = result..'||'..monsterCount
result = result..'||'..Shared.formatnum(Monsters._getMonsterCombatLevel(boss))
result = result..'||'..p._getDungeonRewards(dung, false)
if dung.pet ~= nil then
local pet = GameData.getEntityByID('pets', dung.pet.petID)
if pet ~= nil then
result = result..'||data-sort-value="'..pet.name..'"|'..Icons.Icon({pet.name, type='pet'})
end
else
result = result..'|| '
end
end
result = result..'\r\n|}'
return result
end
return p