require 'makegrid' -- Controls switching between levels ---@class LevelHandler ---@field levels string[] ---@field current integer LevelHandler = { levels = { 'test2', 'test', 'test3' }, current = 1, } -- Switches level to next or cycles if it was the last level ---@return Grid function LevelHandler:next() self.current = self.current + 1 if self.current > #self.levels then self.current = 1 end local levelPath = 'levels/' .. self.levels[self.current] return MakeGrid( require( levelPath ) ) end -- Returns first level ---@return Grid function LevelHandler:first() local levelPath = 'levels/' .. self.levels[1] return MakeGrid( require( levelPath ) ) end -- Returns level by its index in table ---@param i number ---@return Grid function LevelHandler:indexed(i) self.current = i local levelPath = 'levels/' .. self.levels[self.current] return MakeGrid( require( levelPath ) ) end