Documentation for this module may be created at Module:ListCharacters/doc
--[[Category:Flower Knight description modules]]
--This module exists to hold scripts that build lists of Flower Knights based on some attribute.
--Templates should always call MakeList, passing the names of the desired functions as arguments.
--Other arguments can be included to control the output of waifulist and CImage.
local getArgs = require("Module:Arguments").getArgs
local utils = require('Module:Utils')
local MasterCharacterData = require("Module:MasterCharacterData")
local BundledAbilityList = require("Module:BundledAbilityList")
local IconList = require("module:WaifuList")
local y = {}
--MakeList and GetAllKnights are used by all template calls.
function y.MakeList(frame)
args=getArgs(frame:getParent())
list = y.GetAllKnights()
local IconListArgs = {}
for key, arg in pairs(args) do
if y[arg] then list = y[arg](list)
elseif tonumber(key) then table.insert(IconListArgs, arg)
else IconListArgs[key]=arg
end
end
return IconList._list(list, IconListArgs)
end
function y.GetAllKnights()
local ListAll = {}
for jName, data in utils.orderedPairs(MasterCharacterData) do
if data.id <= 100000000 then --Exclude skins.
table.insert(ListAll, jName) --Create the list of all knights that will
end --be processed by any call to this module.
end
return ListAll
end
--Various data sources sit here
y.ExclusiveList = { [133]='', [171]='', [173]='', [182]='', [206]='', [215]='', [224]='', [229]='', [248]='', [253]='' }
--Sorting functions come next.
function y.SortByRarity(OldList) --Sorts the list from highest to lowest rarity
local Sorted = {}
for stars=6,2,-1 do
for key, jName in pairs(OldList) do
if MasterCharacterData[jName].rarity==stars then
table.insert(Sorted, jName)
OldList[key] = nil
end
end
end
return Sorted
end
function y.SortBycharID(OldList) --Sorts the list by release order
local Sorted = {}
for key, jName in pairs(OldList) do --build an array of relevant IDs to be sorted
table.insert(Sorted, MasterCharacterData[jName].charID)
end
table.sort(Sorted)
local MasterCharacterList = {}
for key, data in pairs(MasterCharacterData) do --build a charID to name conversion table
MasterCharacterList[data.charID] = data.name
end
for key, charID in ipairs(Sorted) do --convert the sorted charIDs to jpnames
Sorted[key] = MasterCharacterList[charID]
end
return Sorted
end
--Filtering functions can be found below.
function y.Upgradable(OldList) --Knights that can perform Rarity Growth.
local UpgradeList = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].tier4skill then table.insert(UpgradeList, jName) end
end
return UpgradeList
end
function y.allrainbow(OldList)
local AllSixStars = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].rarity==6 or MasterCharacterData[jName].tier4skill then
table.insert(AllSixStars, jName) end
end
return AllSixStars
end
function y.rainbow(OldList)
local SixStars = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].rarity==6 then
table.insert(SixStars, jName) end
end
return SixStars
end
function y.gold(OldList)
local FiveStars = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].rarity==5 then table.insert(FiveStars, jName) end
end
return FiveStars
end
function y.silver(OldList)
local FourStars = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].rarity==4 then table.insert(FourStars, jName) end
end
return FourStars
end
function y.bronze(OldList)
local ThreeStars = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].rarity==3 then table.insert(ThreeStars, jName) end
end
return ThreeStars
end
function y.copper(OldList)
local TwoStars = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].rarity==2 then table.insert(TwoStars, jName) end
end
return TwoStars
end
function y.SkillRateUp(OldList)
local SkillRateUpKeys = {
[1101] = {},
[1102] = {},
[1104] = {},
[1105] = {},
[1209] = {},
[1303] = {},
}
local SkillRateUpList = {}
for key, jName in ipairs(OldList) do
for key2, IDs in pairs(MasterCharacterData[jName].bundledAbilities) do
local bundle = BundledAbilityList[IDs[1]]
if bundle and (SkillRateUpKeys[bundle['ability1ID']] or SkillRateUpKeys[bundle['ability2ID']] or SkillRateUpKeys[bundle['ability3ID']]) then
table.insert(SkillRateUpList, jName)
break
end
local bundle = BundledAbilityList[IDs[2]]
if bundle and (SkillRateUpKeys[bundle['ability1ID']] or SkillRateUpKeys[bundle['ability2ID']] or SkillRateUpKeys[bundle['ability3ID']]) then
table.insert(SkillRateUpList, jName)
break
end
end
end
return SkillRateUpList
end
function y.twentyfifteen(OldList) --non-event, non-exclusive characters introduced before 2016.
local twentyfifteenList = {}
for key, jName in ipairs(OldList) do
if MasterCharacterData[jName].charID < 155 and
MasterCharacterData[jName].isEvent == 0 and
MasterCharacterData[jName].charID ~= 133 then
table.insert(twentyfifteenList, jName)
end
end
return twentyfifteenList
end
function y.twentysixteen(OldList) --non-event, non-exclusive characters introduced in 2016.
local twentysixteenList = {}
for key, jName in ipairs(OldList) do
local charID = MasterCharacterData[jName].charID
if charID < 275 and MasterCharacterData[jName].isEvent == 0 and charID > 154 and not y.ExclusiveList[charID] then
table.insert(twentysixteenList, jName)
end
end
return twentysixteenList
end
return y