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]

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) -- TODO: sortedPets should move from sortedPets[maxRarity] to sortedPets[maxRarity][maxLevel], so as to account for special cases like the Golden Dragon pet. -- 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] --Assume max level of pet is 100, which will be removed once I rework sortedPets. end end end --Next steps: Access each pet one at a time, and create a UI slot for them. local menu = ' ' menu = menu .. p.petTemplateUI(1, 3) .. p.petTemplateUI(2, 3) .. p.petTemplateUI(3, 3) menu = menu .. ' '	return menu end

function p.petUISlot(pet, rarity, maxLevel) return "TODO" 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 'false' or 'true'), ['fill'] = 'border', }	local ui = Interface(args) if page ~= 1 then ui:setSlot(6, 1, {			'Arrow',			title = '&aPrevious Page',			text = '&ePage ' .. (page - 1),			link = 'none',			class = 'goto-pets-' .. (page - 1),		}, false) end ui:setSlot(6, 2, {			'Autopet Rules 2-Pack',			title = '&cAutopet',			text = '&7Define custom &crules &7to/&7automatically equip your/&7pets.//&7Rules used: &c0\\/14',			link = 'none',			class = 'none',		}, false) ui:setSlot(6, 3, {		'Diamond',		title = '&aPet Score Rewards',		text = '&7Pet Score is calculated based/&7on how many &aunique &7pets you/&7have and the &ararity &7of these/&7pets.//&610 Score&7: &8+&b1 Magic Find/&625 Score&7: &8+&b2 Magic Find/&650 Score&7: &8+&b3 Magic Find/&675 Score&7: &8+&b4 Magic Find/&6100 Score&7: &8+&b5 Magic Find/&6130 Score&7: &8+&b6 Magic Find/&6175 Score&7: &8+&b7 Magic Find/&6225 Score&7: &8+&b8 Magic Find/&6275 Score&7: &8+&b9 Magic Find &5«/&6325 Score&7: &8+&b10 Magic Find//&9Your Pet Score: &f306', --TODO: This should be calculated, and not static		link = 'none',		class = 'none',	}, false)

ui:setSlot(6, 6, {		'Gray Dye', 		title = '&aConvert Pet to an Item', 		text = '&7Enable this setting and click/&7any pet to convert it to an/&7item.//&cDisabled',		link = 'none',		class = 'none',	}, false)

ui:setSlot(6, 7, {		'Stone Button',		title = '&aHide Pets', 		text = '&7Hide all pets which are little/&7heads from being visible in the/&7world.//&7Pet effects remain active.//&7Currently: &aPets shown!/&7Selected pet: &cNone',		link = 'none',		class = 'none',	}, false) if page ~= maxPage then ui:setSlot(6, 9, {			'Arrow',			title = '&aNext Page',			text = '&ePage ' .. (page + 1),			link = 'none',			class = 'goto-pets-' .. (page + 1),		}, false) end return tostring(ui) end

return p