Module:Characters

local p = {} p.characters = mw.loadData('Module:Characters/data') p.quest = mw.loadData('Module:Characters/quests') local f = require('Module:Functions')

p.config = { stats = { geek = "#02e8ab", charmer = "#ff00c8", artist = "#ff8000", jock = "#0062ff", romantic = "#ff0000" },	colors = { premium = "#fe097e", event = "#aa00ff" },	border = { giant = "margin-top: -2.5px;".. "margin-left: 80px;".. "border-radius: 5px;".. "width: 200px;".. "height: 235px;".. "position: absolute;".. "border: 2px solid {color};".. "background: {color}2f", big = "margin-top: 2.5px;".. "margin-left: 10px;".. "border-radius: 50px;".. "width: 60px;".. "height: 60px;".. "position: absolute;".. "border: 2px solid {color};".. "background: {color}2f", medium = "margin-top: 2.5px;".. "margin-left: 6px;".. "border-radius: 50px;".. "width: 61px;".. "height: 61px;".. "position: absolute;".. "border: 1.5px solid {color};".. "background: {color}2f", small = "margin-top: 2.5px;".. "margin-left: 4px;".. "border-radius: 50px;".. "width: 44px;".. "height: 44px;".. "position: absolute;".. "border: 1.5px solid {color};".. "background: {color}2f", },	outfit = "border: 2px solid #3366cc44;".. "background: #f8f9fa;".. "border-radius: 5px;".. "margin: 2px;".. "width:150px;", costIcons = 25,

}

-- Character pages function p.other(frame) if frame.args[1] == "" then return end return frame.args[1] end

function p.infobox(frame) local name = mw.title.getCurrentTitle.text local char_data= p.characters[name] if char_data == nil then return " Please insert data to Module:Characters/data." end local data = {} local infobox = { border = getFrame(char_data.exclusive, "giant"), image = name..'_profile.png', fullName = char_data.fullName, age = char_data.age, height = char_data.height, eyes = char_data.eyes, skin = char_data.skin, hair = char_data.hair, cup = char_data.cup, personality = char_data.personality, likes = char_data.likes, dislikes = char_data.dislikes, bio = char_data.bio, relationships = getRelationships(frame,char_data.relationships,75,4), geek = char_data.defaultStats.geek, color_geek = p.config.stats.geek, charmer = char_data.defaultStats.charmer, color_charmer = p.config.stats.charmer, artist = char_data.defaultStats.artist, color_artist = p.config.stats.artist, jock = char_data.defaultStats.jock, color_jock = p.config.stats.jock, romantic = char_data.defaultStats.romantic, color_romantic = p.config.stats.romantic }   table.insert(data, frame:expandTemplate { title = 'Character info', args = infobox }) return table.concat(data, '\n') end

function p.bio(frame) local name = mw.title.getCurrentTitle.text local char_data= p.characters[name] if char_data == nil then return "" end local data = '==Overview==' .. '\n' .. ' ' .. char_data.bio .. ' ' .. '\n' return data end

function p.outfits(frame) local name = mw.title.getCurrentTitle.text local outfits = mw.loadData('Module:Characters/outfits') local count = 0 local data = { '==Outfits==', ' ',	}	for i, j in pairs(outfits) do 		if(j[name] ~= nil) then table.insert(data, ' '..j.name..' '..getStats(j.stats)..' '..j.acquisition..' ') count = count+1 end end table.insert(data, ' ') for i, j in pairs(data) do mw.log(j) end return table.concat(data, '\n') end

function p.quests(frame) local name = mw.title.getCurrentTitle.text local data = { '==Quests==', ' ',		'{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',		'! Quest', '! Description', '! Explanation', '! Rewards', '|-'	}	local count = 0 for i, j in pairs(p.quest) do		for b,k in pairs(j.characters) do			if(string.match(k,name)) then count = count+1 table.insert(data, '|'..j.title) table.insert(data, '|'..j.description) table.insert(data, '|'..j.explanation) table.insert(data, '|'..getRewards(j.rewards)) table.insert(data, '|-') end end end table.insert(data, '|} ') if(count>0) then return table.concat(data, '\n') end return table.concat({'==Quests=='},'\n') end

--https://collegelife.miraheze.org/wiki/Characters function p.overview(frame) local data = { '==Character List==', ' ',       '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|+ Premium characters are in pink circle', '|+ Event characters are in purple circle', '|-',       '! Character', '! Relationships', '! Gender', '! Available', '|-'   }	local s = {} local sorted = f.sortKeys(p.characters) for _, a in ipairs(sorted) do   	s = p.characters[a]

table.insert(data, '| '..getFrame(s.exclusive, "big")..'  '..a..f.noPage(frame,a,"")..'') if(p.characters[a] ~= nil) then table.insert(data, '| data-sort-value='..getRelationships(frame,s.relationships,55,nil,true)..'| '..getRelationships(frame,s.relationships,55,nil,false,"small")) gender = "female" if(s.gender ~= null) then gender = s.gender end table.insert(data, '| ') cost = "" if(s.cost ~= nil) then cost = " ("..s.cost..' )' end table.insert(data, '| '..check(s.available)..cost) else table.insert(data, '| data-sort-value=0| ?') table.insert(data, '| data-sort-value=0| ?') table.insert(data, '| data-sort-value=0| ?') end table.insert(data, '|-') end table.insert(data, '|}') for i, j in pairs(data) do mw.log(j) end table.insert(data, ' ') return table.concat(data, "\n") end

--https://collegelife.miraheze.org/wiki/Characters/Stats function p.stats local data = { '==Stats List==', ' ',       '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',       '! Character', '! Cup', '! Age', '! Height', '! Skin', '! Hair', '! Eyes', '! Geek', '! Artist', '! Romantic', '! Charmer', '! Jock', '|-'   }    local s = {} local sorted = f.sortKeys(p.characters) for _, a in ipairs(sorted) do       s = p.characters[a] table.insert(data, '| '..a..'') table.insert(data, '|'..s.cup) table.insert(data, '|'..s.age) table.insert(data, '|'..s.height) table.insert(data, '|'..s.skin) table.insert(data, '|'..s.hair) table.insert(data, '|'..s.eyes) table.insert(data, '|'..s.defaultStats.geek) table.insert(data, '|'..s.defaultStats.artist) table.insert(data, '|'..s.defaultStats.romantic) table.insert(data, '|'..s.defaultStats.charmer) table.insert(data, '|'..s.defaultStats.jock) table.insert(data, '|-') end table.insert(data, '|}') return table.concat(data, "\n") end

--https://collegelife.miraheze.org/wiki/Characters/Quests function p.quests local data = { '==Quests List==', ' ',       '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',       '! Quest', '! Description', '! Explanation ', '! Characters', '! Rewards', '|-'	}	for i, j in pairs(p.quest) do	end table.insert(data,'|}') return table.concat(data, "\n") end

function check(num,c) if (num == nil or num == "")==true then return 'Add here.' else return num end end

function getFrame(exclusive,size) if(exclusive == nil) then return "" end local color = p.config.colors[f.trim(f.split(exclusive,"-")[1]):lower] return ' ' end p.getFrame = getFrame

function getRelationships(frame,list,pixels,newline,_count,size) characters = ' ' count = 1 for s, a in pairs(list) do		if(newline ~= nil and newline ~= 0 and (count-1)%newline == 0) then characters = characters.." " end characters = characters..' '..getFrame(p.characters[a].exclusive,size or "medium")..' '..a..f.noPage(frame,a,"")..'  ' count = count+1 end if(_count) then return count-1 end return characters.." " end

function inList(what,list) for i, j in pairs(list) do		if(string.match(j,what)) then return true end end return false end

function getRewards(data) local rewards = "" local hasIcon = {"xp","money","kiss"} local link = "" for i, j in pairs(data) do		if(inList(i, hasIcon)) then link = '' else link = f.upfirst(i) end rewards = rewards..link.." "..j.." " end return rewards end

function getStats(data) local stats = "" if(data == nil) then return stats end for i, j in pairs(data) do 		stats = stats..''..f.upfirst(i)..' '..j..' ' end return stats end

function getAcquisition(data) local acq = "" if(data == nil) then return acq end local c = 0 for i, j in pairs(data) do 		if(c>0) then acq = acq..", " end acq = acq..j		c = c+1 end return acq end

p.getStats = getStats p.getAcquisition = getAcquisition

return p