Module:Pet/UI

local loader = require('Module:Loader') local petData = require('Module:Pet/Data') local rarityData = require('Module:RarityTier/Data')

local string, table, rarityTier, invslot, Interface = loader.lazy.require('String', 'Table', 'RarityTier', 'Inventory slot', 'UI/Core') local p = {}

function p.petUI local petsByRarity = {} local sortedPets = {} for k in pairs(petData) do		mw.log(k) pet = petData[k] --mw.logObject(pet)

maxRarity = pet["rarities"][#pet["rarities"]] mw.log(maxRarity) if not petsByRarity[maxRarity] then petsByRarity[maxRarity] = {} end petsByRarity[maxRarity][k] = pet if not sortedPets[maxRarity] then sortedPets[maxRarity] = {k} else table.insert(sortedPets[maxRarity], k)		end end --mw.logObject(petsByRarity) --mw.logObject(sortedPets) -- This list is ordered from common upwards, so we need to reverse it, or iterate in reverse order, to get the desired order. orderedRarities = rarityTier._orderedTiers for a = #orderedRarities, 1, -1 do		rarityCode = string.upper(rarityData[orderedRarities[a]]['short']) mw.log(rarityCode) if sortedPets[rarityCode] then table.sort(sortedPets[rarityCode]) for b = 1, #sortedPets[rarityCode] do				petName = sortedPets[rarityCode][b] local pet = petsByRarity[rarityCode][petName] end end end --Next steps: Access each pet one at a time, and create a UI slot for them. return 'WIP ' .. p.petTemplateUI(1, 3) end

function p.petTemplateUI(page, maxPage) local args = { ['topText'] = '(' .. page .. '/' .. maxPage .. ') Pets', ['id'] = 'pets-' .. page, ['goback'] = '&7To SkyBlock Menu', ['return_id'] = 'default', ['hide'] = (page == 1) and 'true' or 'false', ['fill'] = 'border', }	local ui = Interface(args) return tostring(ui) end

return p