Module:Decorations

local p = {} p.deco = mw.loadData('Module:Decorations/data') p.seed = mw.loadData('Module:Decorations/seedcatalog') p.config = { color = { flowers = "#9ee89e", decor = "#a9d3eb", trees = "#d6b792", other = "#f29dde" },	starsMin = 0.5, starsMax = 3, starsStep = 0.5 } local f = require('Module:Functions')

function benefit(value) stars = "" local val = value if(val ~= math.floor(val)) then stars = "" end val = math.floor(val) while val>0 do		stars = ""..stars val = val-1 end return stars end

function costType(type) if(string.match("kiss",type)) then return "" end if(string.match("money",type)) then return "" end return " "..type end

function decos(j) local data = "" color = p.config.color[j.type] if(j.other ~= nil) then color = p.config.color.other end data = data..' '..j.name.." "..j.cost..costType(j.costType).." " return data end function p.table local data = {} for i, j in pairs(p.config.color) do		table.insert(data, ' '..f.upfirst(i)..' ') end table.insert(data,' ') table.insert(data,'{| class="wikitable mw-datatable" style="text-align: center;"') table.insert(data,'|-') local stars = { unknown = {}, }	for i in f.range(p.config.starsMin,p.config.starsMax,p.config.starsStep) do table.insert(data,"! "..benefit(i)) stars[i] = {} end table.insert(data,'! Unknown') table.insert(data,'|-') for i, j in pairs(p.deco) do		star = j.benefit if (star == nil or type(star) ~= "number") then table.insert(stars["unknown"], '|'..decos(j)) else table.insert(stars[j.benefit], '|'..decos(j)) end end for i in f.range(p.config.starsMin,p.config.starsMax,p.config.starsStep) do		table.insert(data, '|'..table.concat(stars[i],"\n")) end table.insert(data, '|'..table.concat(stars["unknown"],"\n")) table.insert(data, '|-') table.insert(data, '|}') table.insert(data, ' ') return table.concat(data,"\n") end

function empty(what) if what ~= nil then return what end return "" end function p.stats --{type="", name="", cost=0, costType="money", benefit=0, space=0, playerLvl = nil, other = nil}, local data = { ' ',		'{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',		'! Type', '! Name', '! Cost', '! Cost Type', '! Benefit', '! Space', '! Player LvL', '! Other', '|-'	}	for i, j in pairs(p.deco) do		table.insert(data, '|'..f.upfirst(empty(j.type))) table.insert(data, '|'..empty(j.name)) table.insert(data, '|'..empty(j.cost)) table.insert(data, '|'..costType(empty(j.costType))) table.insert(data, '|'..empty(j.benefit)) table.insert(data, '|'..empty(j.space)) table.insert(data, '|'..empty(j.playerLvl)) table.insert(data, '|'..empty(j.other)) end table.insert(data, '|}') table.insert(data, ' ') return table.concat(data,"\n") end

local function decoPics(decos) local data = "" local items = {} local c = 0 for i, j in pairs(decos) do 		if not(f.has_value(items,j)) then table.insert(items,j) if(c>0) then data = data.." " end c = c+1 data = data..j		end end return data end

local function dataTime(xTime) local data = ' ' return data end

function p.seedsbycharacter local data = { ' ',		'{| class="wikitable mw-datatable sortable" style="text-align: center;"', '|-',		'! Character', '! class="unsortable" | Orange seed', '! class="unsortable" | Green seed', '! class="unsortable" | Yellow seed', '! class="unsortable" | Purple seed', '|-'	}	local c = require('Module:Characters') for i, j in pairs(p.seed) do 		character = c.characters[i] premium = "" if(character ~= nil and character.currency == "kiss") then premium = ' 'end table.insert(data,'|'..' '..premium..' '..i..'') table.insert(data,'| style="padding:0px;vertical-align: top;"|'..dataTime(j["Orange"])) table.insert(data,'| style="padding:0px;vertical-align: top;"|'..dataTime(j["Green"])) table.insert(data,'| style="padding:0px;vertical-align: top;"|'..dataTime(j["Yellow"])) table.insert(data,'| style="padding:0px;vertical-align: top;"|'..dataTime(j["Purple"])) table.insert(data,'|-') end table.insert(data,'|}') table.insert(data,' ') table.insert(data, 'Data provided by: landarr#5256') return table.concat(data,"\n") end

local function getDecoOfTime(xTime, rarity) local data = "" local items = {} c = 0 for i, j in pairs(p.seed) do 		if(j[rarity][xTime] ~= nil) then for a, b in pairs(j[rarity][xTime]) do				if not(f.has_value(items,b)) then table.insert(items,b) if(c>0) then data = data.." " end c = c+1 data = data..b				end end end end return data end

function p.seeds local data = { ' ',		'{| class="wikitable mw-datatable" style="text-align: center;"', '|-',		'! Time', '! Orange seed', '! Green seed', '! Yellow seed', '! Purple seed', '|-'	}	local dtime = {} for i, j in pairs(p.seed) do 		for a, b in pairs(j["Orange"]) do			if not(f.has_value(dtime,a)) then table.insert(dtime,a) end end for a, b in pairs(j["Green"]) do			if not(f.has_value(dtime,a)) then table.insert(dtime,a) end end for a, b in pairs(j["Yellow"]) do			if not(f.has_value(dtime,a)) then table.insert(dtime,a) end end for a, b in pairs(j["Purple"]) do			if not(f.has_value(dtime,a)) then table.insert(dtime,a) end end end for i, j in pairs(f.sortTable(dtime)) do		table.insert(data, '|'..f.time(j)) table.insert(data, '|'..getDecoOfTime(j,"Orange")) table.insert(data, '|'..getDecoOfTime(j,"Green")) table.insert(data, '|'..getDecoOfTime(j,"Yellow")) table.insert(data, '|'..getDecoOfTime(j,"Purple")) table.insert(data, '|-') end table.insert(data, '|}') table.insert(data, ' ') table.insert(data, 'Data provided by: landarr#5256') for i, j in pairs(data) do mw.log(j) end return table.concat(data,"\n") end

return p