-- lx-bundle:true

--- Register XL Tetris without loading the game at startup
-- @module plugins.xltetris

local command = require("core.command")
local common = require("core.common")
local config = require("core.config")
local keymap = require("core.keymap")

-- Keep settings available to user configuration before the game loads
config.plugins.tetris = common.merge({
	tick = 0.5,
	height = 30,
	width = 10,
	cell_size = 18,
	cell_padding = 2,
	drop_shadow = true,
	lock_delay = 3,
	down_amount = 1,
}, config.plugins.tetris)

local main

--- Load the game on its first start
-- @return table implementation
local function get_main()
	if not main then
		main = require("plugins.xltetris.main")
	end

	return main
end

command.register({
	["tetris:start"] = function()
		return get_main().start()
	end,
})

keymap.bind("plugin", {
	global = {
		["shift+alt+t"] = { "tetris:quit", "tetris:start" },
	},
})
