def test_torch_wire(self): """ Wires will connect to torches. """ asic = Asic() wire = Wire((0, 0, 0), blocks["redstone-wire"].slot, 0x0) torch = Torch((0, 0, 1), blocks["redstone-torch"].slot, blocks["redstone-torch"].orientation("-z")) wire.connect(asic) torch.connect(asic) self.assertTrue(wire in torch.outputs) self.assertTrue(torch in wire.inputs)
def test_update_wires_single(self): torch = Torch((0, 0, 0), blocks["redstone-torch-off"].slot, blocks["redstone-torch"].orientation("-x")) wire = Wire((1, 0, 0), blocks["redstone-wire"].slot, 0x0) plain = PlainBlock((2, 0, 0), blocks["sand"].slot, 0x0) torch.connect(self.asic) wire.connect(self.asic) plain.connect(self.asic) wires, outputs = self.asic.update_wires(1, 0, 0) self.assertTrue(wire in wires) self.assertTrue(plain in outputs) self.assertFalse(wire.status) self.assertEqual(wire.metadata, 0)
def test_wire_sand_below(self): """ Wire will power the plain block beneath it. """ asic = Asic() sand = PlainBlock((0, 0, 0), blocks["sand"].slot, 0x0) wire = Wire((0, 1, 0), blocks["redstone-wire"].slot, 0x0) sand.connect(asic) wire.connect(asic) wire.status = True sand.update() self.assertTrue(wire.status) wire.status = False sand.update() self.assertFalse(wire.status)
def test_update_wires_multiple_powered(self): torch = Torch((0, 0, 0), blocks["redstone-torch"].slot, blocks["redstone-torch"].orientation("-x")) wire = Wire((1, 0, 0), blocks["redstone-wire"].slot, 0x0) wire2 = Wire((1, 0, 1), blocks["redstone-wire"].slot, 0x0) plain = PlainBlock((2, 0, 0), blocks["sand"].slot, 0x0) torch.connect(self.asic) wire.connect(self.asic) wire2.connect(self.asic) plain.connect(self.asic) torch.status = True wires, outputs = self.asic.update_wires(1, 0, 0) self.assertTrue(wire in wires) self.assertTrue(wire2 in wires) self.assertTrue(plain in outputs) self.assertTrue(wire.status) self.assertEqual(wire.metadata, 15) self.assertTrue(wire2.status) self.assertEqual(wire2.metadata, 14)