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, uiModule = loader.lazy.require('String', 'Table', 'RarityTier', 'Inventory slot', 'UI') 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 i = #orderedRarities, 1, -1 do		rarityCode = string.upper(rarityData[orderedRarities[i]]['short']) mw.log(rarityCode) if sortedPets[rarityCode] then table.sort(sortedPets[rarityCode]) end end --Next steps: Access each pet one at a time, and create a UI slot for them. return 'WIP' end

return p