Module:HeroListBySummonRarity

local p = {} local cargo = mw.ext.cargo local Util = require 'Module:Util' local HeroUtil = require 'Module:HeroUtil' local List = require 'Module:ListUtil' local HeroTableBuilder = require 'Module:HeroTableBuilder'

local RARITY_TXT = Util.getRarityTexts

local specialList = function -- Cargo Query local availability = HeroUtil.getLowestRarities {current = true, mask = {focus = true}} local heroQueryResult = cargo.query('Units', "_pageName,IFNULL(CONCAT(Name,': ',Title),Name)=Name,Entries,WeaponType,MoveType,Properties__full", {		where = "Properties HOLDS 'special' OR Properties HOLDS 'legendary' OR Properties HOLDS 'mythic'",		groupBy = '_pageName',		limit = 1000,	})

local theUnit = nil local builder = HeroTableBuilder.new

builder:heroIcon('40px'):css('width', '40px') builder:heroLink:css('width', '50%') builder:heroEntry:css('width', '10%'):css('min-width', '30px') builder:moveType:css('width', '10%'):css('min-width', '30px') builder:weaponType:css('width', '10%'):css('min-width', '30px') builder:column('Rarities', function (elem)		local minrarity, maxrarity = availability[theUnit._pageName]:bounds		elem:wikitext(minrarity == maxrarity and RARITY_TXT[minrarity] or ('%s – %s'):format(RARITY_TXT[minrarity], RARITY_TXT[maxrarity]))		if theUnit.Properties__full:find('legendary') then			elem:wikitext(' — Legendary')		elseif theUnit.Properties__full:find('mythic') then			elem:wikitext(' — Mythic')		elseif theUnit.Properties__full:find('special') then			elem:wikitext(' — Special')		end	end):css('width', '30%'):css('min-width', '65px')

for _, v in ipairs(heroQueryResult) do		theUnit = v		builder:addHero(v._pageName, v.Name, v.MoveType, v.WeaponType, v.Entries) end

return builder:build:addClass('wikitable'):addClass('default'):css('text-align', 'center')--:css('width', '100%') end

local normalList = function (args) local rarity = tonumber(args[1]) local heroQueryResult = cargo.query(		'SummoningAvailability,Units',		"Units._pageName=Page,IFNULL(CONCAT(Name,': ',Title),Name)=Name,Entries,WeaponType,MoveType,GROUP_CONCAT(DISTINCT Rarity SEPARATOR ',')=rarities", {			join = 'SummoningAvailability._pageName=Units._pageName',			where = 'NOW BETWEEN StartTime AND EndTime',			groupBy = 'Units._pageName',			limit = 1000,		}) for _, v in ipairs(heroQueryResult) do		v.minrarity, v.maxrarity = List.minmax(List.map_self(mw.text.split(v.rarities, '%s*,%s*'), function (x) return tonumber(x) end)) end List.keep_if(heroQueryResult, function (v)		return v.minrarity and rarity >= v.minrarity and v.maxrarity and rarity <= v.maxrarity	end)

local theUnit = nil local builder = HeroTableBuilder.new

builder:heroIcon('40px'):css('width', '40px') builder:heroLink:css('width', '50%') builder:heroEntry:css('width', '10%'):css('min-width', '30px') builder:moveType:css('width', '10%'):css('min-width', '30px') builder:weaponType:css('width', '10%'):css('min-width', '30px') builder:column('Rarities', function (elem)		elem:wikitext(RARITY_TXT[theUnit.minrarity])		if theUnit.minrarity ~= theUnit.maxrarity then			elem:wikitext(' – ', RARITY_TXT[theUnit.maxrarity])		end	end):css('width', '30%'):css('min-width', '65px')

for _, v in ipairs(heroQueryResult) do		theUnit = v		builder:addHero(v.Page, v.Name, v.MoveType, v.WeaponType, v.Entries) end

return builder:build:addClass('wikitable'):addClass('default'):css('text-align', 'center')--:css('width', '100%') end

return require 'Module:MakeMWModule'.makeMWModule { normalList = normalList, specialList = specialList, }