From 4e889cae1848a0e589f4fe94e83fbd91c1f9fcc2 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Wed, 19 Feb 2025 11:00:03 +0800 Subject: refactor: separate logic and object --- objects/room.lua | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'objects/room.lua') diff --git a/objects/room.lua b/objects/room.lua index 0edac69..4ae92ab 100644 --- a/objects/room.lua +++ b/objects/room.lua @@ -55,35 +55,4 @@ function Room:addDoor(door) table.insert(self.doors, door) end -function Room.switch(to) - local destination - if type(to) == "table" then - destination = to - elseif type(to) == "number" then - destination = G.currentRoom.doors[Direction[to]] - end - - G.currentRoom = destination - G.enemies = destination.enemies -end - -function Room.generate(roomCount) - local rooms = {} - local room1 = Room:new() - table.insert(rooms, room1) - - for i = 2, roomCount do - local newRoom = Room:new() - local previousRoom = rooms[math.random(#rooms)] - - newRoom.enemies = Enemy.generate(math.random(3,6), newRoom) - - Door.connect(previousRoom, newRoom, math.random(4)) - - table.insert(rooms, newRoom) - end - - return rooms[1] -end - return Room -- cgit v1.2.3