Exemplo n.º 1
0
 def test_peek_limit(self):
     self.begin_for_testing()
     down(90)
     forward(300)
     self.assertEqual(None, peek())
     up(180)
     forward(700)
Exemplo n.º 2
0
    def test_forward_outside_of_game_boundaries_just_doesnt_attempt_to_lay_blocks__more_than_max_y(
            self):
        self.game.player.tile_pos = Vector(100, 253, 300)
        self.game.player.rotation = 2
        self.begin_for_testing(start_distance_from_player=5)

        up(90)
        forward(10)

        self.assertEqual(
            {
                (100, 253, 305): "gold_block",
                (100, 254, 305): "gold_block",
                (100, 255, 305): "gold_block"
            }, self.game.tiles)
Exemplo n.º 3
0
    def test_turn_methods_take_valid_degrees(self):
        self.begin_for_testing()

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, right\(abc\) won't work. Degrees must be a number."):
            right('abc')

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, left\(abc\) won't work. Degrees must be a number."):
            left('abc')

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, up\(abc\) won't work. Degrees must be a number."):
            up('abc')

        with self.assertRaisesRegexp(
                AssertionError,
                "Oops, down\(abc\) won't work. Degrees must be a number."):
            down('abc')
Exemplo n.º 4
0
    def test_up_over_360(self):
        self.begin_for_testing()
        forward(1)
        up(3690)

        self.assertEqual(
            {
                (100, 200, 300): "gold_block",
                (100, 200, 301): ("piston", {
                    "facing": "up"
                })
            }, self.game.tiles)

        forward(2)

        self.assertEqual(
            {
                (100, 200, 300): "gold_block",
                (100, 200, 301): "gold_block",
                (100, 201, 301): "gold_block",
                (100, 202, 301): ("piston", {
                    "facing": "up"
                })
            }, self.game.tiles)
Exemplo n.º 5
0
    def test_turns_and_piston_facing(self):
        self.begin_for_testing()
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)
        right(30)
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)
        right(30)  # yaw 60
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "west"
                          })}, self.game.tiles)
        right(30)  # yaw 90 - due west
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "west"
                          })}, self.game.tiles)
        right(30)  # yaw 120
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "west"
                          })}, self.game.tiles)
        right(30)  # yaw 150
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "north"
                          })}, self.game.tiles)
        right(30)  # yaw 180 - due north
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "north"
                          })}, self.game.tiles)
        right(30)  # yaw 210
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "north"
                          })}, self.game.tiles)
        right(30)  # yaw 240
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "east"
                          })}, self.game.tiles)
        right(30)  # yaw 270 - due east
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "east"
                          })}, self.game.tiles)
        right(30)  # yaw 300
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "east"
                          })}, self.game.tiles)
        right(30)  # yaw 330
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)
        right(30)  # yaw 360
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)

        up(30)  # pitch 60
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)
        up(30)  # pitch 30
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "up"
                          })}, self.game.tiles)
        up(30)  # pitch 0 - straight up
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "up"
                          })}, self.game.tiles)
        up(30)  # pitch 330
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "up"
                          })}, self.game.tiles)
        up(30)  # pitch 300
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "north"
                          })}, self.game.tiles)
        up(30)  # pitch 270
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "north"
                          })}, self.game.tiles)
        up(30)  # pitch 240
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "north"
                          })}, self.game.tiles)
        up(30)  # pitch 210
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "down"
                          })}, self.game.tiles)
        up(30)  # pitch 180 - straight down
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "down"
                          })}, self.game.tiles)
        up(30)  # pitch 150
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "down"
                          })}, self.game.tiles)
        up(30)  # pitch 120
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)
        up(30)  # pitch 90
        self.assertEqual({(100, 200, 300): ("piston", {
                              "facing": "south"
                          })}, self.game.tiles)