better wirer behavior etc

This commit is contained in:
Your Name 2026-08-12 00:12:26 -04:00
parent bc4976b324
commit 6a5c2fc951
24 changed files with 11347 additions and 8198 deletions

View file

@ -183,6 +183,54 @@ test("a door requires every independent switch run at its terminal", function()
assertTrue(world.circuitState.doorPowered[wiredDoor])
end)
test("an orphaned stub at a door does not block a valid switch run", function()
local world, roomA, _, wiredDoor = makeWorld()
roomA.wires[1][1].abandoned_stroke = 0
world.collidableMatrices.blue[1] = {[4] = {}}
world:resolveCircuits()
assertTrue(world.circuitState.doorPowered[wiredDoor])
assertTrue(wiredDoor.powered)
end)
test("selecting a parked colour changes to its room", function()
local function player()
local entity = {switched = false}
function entity:playSwitchSound(success) self.switched = success end
return entity
end
local function room(name, players, active)
local entity = {name = name, player = players, activeColors = active, colorsPlayerHas = {}}
for color in pairs(players) do table.insert(entity.colorsPlayerHas, color) end
function entity:getPossibleColors() return self.colorsPlayerHas end
function entity:setActiveColor(color, value) self.activeColors[color] = value end
function entity:getActiveColors()
local colors = {}
for color, value in pairs(self.activeColors) do if value then table.insert(colors, color) end end
return colors
end
return entity
end
local roomA = room("a", {red = player()}, {red = true, green = false, blue = false})
local roomB = room("b", {blue = player()}, {red = false, green = false, blue = false})
local world = setmetatable({
levels = {a = roomA, b = roomB},
roomByName = {a = {name = "a", x = 1, y = 1}, b = {name = "b", x = 2, y = 1}},
}, {__index = World})
world.flushRuntime = function(self) self.flushed = true end
local oldCurrentRoom, oldSetEditorRoomName = currentRoom, setEditorRoomName
currentRoom = roomA
setEditorRoomName = function() end
assertTrue(world:switchPlayerColor(roomA, "blue"))
assertTrue(currentRoom == roomB)
assertFalse(roomA.activeColors.red)
assertTrue(roomB.activeColors.blue)
assertTrue(roomB.player.blue.switched)
assertTrue(world.flushed)
currentRoom, setEditorRoomName = oldCurrentRoom, oldSetEditorRoomName
end)
test("one run cannot terminate at two different switches", function()
local second = switch("red", 1, 2)
local world, _, roomB = makeWorld(second)