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" },	premiumbig = "margin-top: 2.5px;".. "margin-left: 10px;".. "border-radius: 50px;".. "width: 60px;".. "height: 60px;".. "position: absolute;".. "border: 2px solid #fe097e;", premiumsmall = "margin-top: 2.5px;".. "margin-left: 4px;".. "border-radius: 50px;".. "width: 44px;".. "height: 44px;".. "position: absolute;".. "border: 1.5px solid #fe097e;", premium = "margin-top: 2.5px;".. "margin-left: 6px;".. "border-radius: 50px;".. "width: 61px;".. "height: 61px;".. "position: absolute;".. "border: 1.5px solid #fe097e;", costIcons = 25,

}

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

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

function getRelationships(frame,list,pixels,newline,_count,small) 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 premium = "" if(p.characters[a].currency == "kiss") then if(small) then premium = ' ' else premium = ' ' end end characters = characters..' '..premium..' '..a..f.noPage(frame,a,"")..' ' count = count+1 end if(_count) then return count-1 end return characters.." " 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 = { 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 getStats(data) local stats = "" for i, j in pairs(data) do 		stats = stats..''..f.upfirst(i)..' '..j..' ' end return stats end

p.getStats = getStats

function p.outfits(frame) local name = mw.title.getCurrentTitle.text local char_data= p.characters[name] if char_data == nil then return "" end local count = 1 local data = { '==Outfits==', ' ',		'{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',	}	for i, j in pairs(char_data.outfits) do 		if(count%6 == 0) then table.insert(data, '|-') end table.insert(data, '| '..j.name..' '..getStats(j.stats)..' '..j.acquisition) count = count+1 end table.insert(data, '|-') local c = count-1 if(count>6) then c = 6 end table.insert(data, '|} ') return table.concat(data, '\n') 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 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

local function getPicture(name) local character = p.characters[name] premium = "" if(s.currency == "kiss") then premium = ' 'end return ' '..premium..' '..a..f.noPage(frame,a,"")..'' end p.getPic = getPicture

function p.table(frame) local data = { '==Character List==', ' ',       '{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|+ Premium characters are in pink circle', '|-',       '! Character', '! Relationships', '! Gender', '! Available', '|-'   }	local s = {} local sorted = f.sortKeys(p.characters) for _, a in ipairs(sorted) do   	s = p.characters[a] premium = "" if(s.currency == "kiss") then premium = ' 'end table.insert(data, '| '..premium..' '..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,true)) 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

function p.stats local data = { '==Stats List==' }	return table.concat(data, "\n") end

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

return p