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 local stars = { unknown = "", }	for i in f.range(p.config.starsMin,p.config.starsMax,p.config.starsStep) do		stars[i] = "" end for i, j in pairs(p.deco) do		star = j.benefit if (star == nil or type(star) ~= "number") then stars["unknown"] = stars["unknown"]..decos(j) else stars[j.benefit] = 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, '=='..benefit(i)..'==') table.insert(data, ' ') table.insert(data, stars[i]) table.insert(data, ' ') end if(f.length(stars["unknown"])>0) then table.insert(data, '==unknown==') table.insert(data, ' ') table.insert(data, stars["unknown"]) table.insert(data, ' ') end return table.concat(data,"\n") 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((j.type or ''))) table.insert(data, '|'..(j.name or '?')) table.insert(data, '|'..(j.cost or '?')) table.insert(data, '|'..costType((j.costType or '?'))) table.insert(data, '|'..(j.benefit or '?')) table.insert(data, '|'..(j.space[1] or '?')..'x'..(j.space[2] or '?')) table.insert(data, '|'..(j.playerLvl or '')) table.insert(data, '|'..(j.other or '')) table.insert(data, '|-') 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] table.insert(data,'|'..' '..c.getFrame(character.exclusive,'big')..' '..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