Module:Blueprint

local blueprint = {}

-- Load modules local iter = require("Module:Functional").iter

local data = require("Module:Data") local item = require("Module:Item")

local CargoUtils = require("Module:CargoUtils")

-- Blueprint-related constants local RARITIES = table.concat(iter(data.RARITY_COLORS):keys:totable, ',')

-- Represents a blueprint in the game. local Blueprint = data.Entity:subclass("Blueprint") blueprint.Blueprint = Blueprint

Blueprint.static.ATTRIBUTE_TABLE = CargoUtils.CargoTable("Blueprint",	{		["name"] = { "String", { mandatory = true }, { "NOT NULL" } },		["image"] = { "File", { mandatory = true }, { "NOT NULL" } },		["rarity"] = { "String", { mandatory = true, ["allowed values"] = RARITIES }, { "NOT NULL" } },		["xp"] = { "Integer" },		["pieces"] = { "Integer" },	},	{ "_pageName" })

-- Static methods -- -- Returns a new Blueprint instance with properties according to the record stored in the given page. function Blueprint.static:fromPageName(fullpagename) assert(type(fullpagename) == type(""), "`fullpagename` must be a string") local query_args = {where = string.format("_pageName = '%s'", fullpagename)} return Blueprint(self.ATTRIBUTE_TABLE:query(query_args, true)[1]) end

-- Module call from Template:Blueprint Definition function blueprint.declareTable( frame ) return Blueprint.ATTRIBUTE_TABLE:declare(frame) end

-- Module call from Template:Blueprint Definition function blueprint.define( frame ) local args = require("Module:Args").getCleanArgs local bp_to_store = Blueprint(args) local store = bp_to_store:storeToTable(Blueprint.ATTRIBUTE_TABLE) return store .. tostring(bp_to_store:generateInfobox) end

-- Module call from Template:Blueprint Infobox function blueprint.generateInfobox( frame ) local args = require("Module:Args").getCleanArgs local fullpagename = "Blueprint:" .. assert(args.full_name, "Missing argument `full_name`") local general_only = args.general_only local no_categories = args.no_categories return Blueprint:fromPageName(fullpagename):generateInfobox(general_only, no_categories) end

return blueprint