def test_custom_plane(self): result = Plane(x=[0, 2], z=[3, 5]) self.assertListEqual([0, 2], result.x_boundaries()) self.assertListEqual([3, 5], result.z_boundaries()) self.assertEqual(0, result.west_edge) self.assertEqual(2, result.east_edge) self.assertEqual(3, result.south_edge) self.assertEqual(5, result.north_edge)
def test_platform_leaves_gap_at_the_end_raises_error(self): try: r = ParallelPlatformer(number_blocks=1, block_size=3, plane=Plane(z=[0, 11])) print(r.__dict__) self.assertTrue(False) except AssertionError as e: self.assertTrue(True) self.assertEqual(e.message, 'Gap too wide')
def the_platform(xz=None): block_id = block.WOOD_PLANKS.id plane = Plane(x=xz[0], z=xz[1]) platform = Platformer(number_blocks=NUMBER_BLOCKS, block_size=PLATFORM_BLOCK_SIZE, plane=plane) #create the platform shapes platform_shapes = [] for pos in platform.get_block_positions(): block_pos = Vec3(pos[0], arenaPos.y, pos[1]) platform_blocks = [] for x in range(PLATFORM_BLOCK_SIZE): for z in range(PLATFORM_BLOCK_SIZE): platform_blocks.append(minecraftstuff.ShapeBlock(x, 0, z, block_id)) platform_shape = minecraftstuff.MinecraftShape(mc, block_pos, platform_blocks) platform_shapes.append(platform_shape) #move the platforms while not levelComplete: platform.move_blocks() directions = platform.get_block_directions() for i in range(len(directions)): platform_shapes[i].moveBy(directions[i][0], 0, directions[i][1]) time.sleep(PLATFORM_SLEEP_TIME)
def _set_plane(self, plane): self._plane = plane if plane else Plane() self._initialize_plane_edges()
def test_platform_successfully_created_with_different_number_of_blocks_and_sizes(self): r = ParallelPlatformer(number_blocks=4, plane=Plane(z=[0, 11])) r = ParallelPlatformer(number_blocks=3, block_size=3, plane=Plane(z=[0, 11])) r = ParallelPlatformer(number_blocks=1, block_size=5, plane=Plane([0, 7], [0, 7]))
def test_basic_custom_platform(self): result = ParallelPlatformer(number_blocks=4, plane=Plane(z=[0, 11])) self.assertEqual(4, len(result.get_block_positions())) self.assertEqual(len(result.get_block_positions()), len(list(set(result.get_block_positions())))) self.assertEqual(len(result.get_block_positions()), len(result.get_block_directions()))
def test_10_blocks_of_bigger_size_move_30_iterations_successfully(self): platform = ParallelPlatformer(number_blocks=2, block_size=5, plane=Plane(z=[0, 12])) for i in range(30): platform.move_blocks() self.assertEqual(2, len(platform.get_block_positions())) self.assertEqual(len(platform.get_block_positions()), len(list(set(platform.get_block_positions()))))
def test_default_plane(self): result = Plane() self.assertListEqual([0, 10], result.x_boundaries()) self.assertListEqual([0, 10], result.z_boundaries())