Пример #1
0
 def test_set_move(self):
     gb = Gameboard(self._testboard, self._characters)
     assert (gb._active_mob_name == u"")
     assert (gb._number_of_moves_remaining == 0)
     gb.set_active_mob(u"Mob1", 10)
     assert (gb._active_mob_name == u"Mob1")
     assert (gb._number_of_moves_remaining == 10)
Пример #2
0
 def test_get_random_pos(self):
     gb = Gameboard(self._testboard, self._characters)
     unoccupied_ones = [(2, 6), (3, 5), (3, 6)]
     res = set()
     for i in range(100):
         res.add(gb.get_random_free_pos_in_room(1))
     assert ((1, 5) not in res)
     for tile in unoccupied_ones:
         assert (tile in res)
Пример #3
0
 def test_prohibit_room_reentry(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob2", 10)
     assert (gb.move_mob(u"Mob2", u"down") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"left") == True)
     assert (gb.move_mob(u"Mob2", u"left") == False)
     assert (gb.get_active_mob_name() == u"Mob2")
Пример #4
0
 def test_decrease_movement_ctr(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob2", 2)
     gb.decrease_movement_counter()
     assert (gb._number_of_moves_remaining == 1)
     gb.decrease_movement_counter()
     assert (gb._active_mob_name == u"")
     assert (gb._number_of_moves_remaining == 0)
Пример #5
0
 def test_move_through_door(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob2", 10)
     mob = gb.get_mob(u"Mob2")
     assert (gb.move_mob(u"Mob2", u"down") == True)
     assert (gb.move_mob(u"Mob2", u"left") == True)
     assert (gb.move_mob(u"Mob2", u"left") == True)
Пример #6
0
 def test_track_rooms(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob2", 10)
     assert (gb.move_mob(u"Mob2", u"down") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb._start_room == 2)
Пример #7
0
 def test_finish_movement(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob2", 3)
     gb.movement_done()
     assert (gb._active_mob_name == u"")
     assert (gb._number_of_moves_remaining == 0)
     assert (gb._start_room == 0)
Пример #8
0
 def test_space_occupied(self):
     gb = Gameboard(self._testboard, self._characters)
     assert (gb.pos_occupied((0, 0)) == False)
     for name, pos in self._characters:
         assert (gb.pos_occupied(pos) == True)
Пример #9
0
 def test_get_positions(self):
     gb = Gameboard(self._testboard, self._characters)
     for name, pos in self._characters:
         assert (pos in gb.get_mobs_pos())
Пример #10
0
 def test_todict(self):
     gb = Gameboard(self._testboard, self._characters)
     data = gb.todict()
     assert (len(data) == len(self._characters))
     for itm in self._characters:
         assert (data[itm[0]] == itm[1])
Пример #11
0
 def test_get_room(self):
     gb = Gameboard(self._testboard, self._characters)
     assert (gb.get_room_no(u"Mob1") == 1)
     assert (gb.get_room_no(u"Mob2") == 2)
Пример #12
0
 def test_is_in_hallway(self):
     gb = Gameboard(self._testboard, self._characters)
     assert (gb.is_in_hallway(u"Mob1") == True)
     assert (gb.is_in_hallway(u"Mob2") == False)
Пример #13
0
 def test_move_into_room(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob2", 10)
     assert (gb.move_mob(u"Mob2", u"down") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"right") == True)
     assert (gb.move_mob(u"Mob2", u"up") == False)
     assert (gb.get_active_mob_name() == u"")
     assert (gb.get_mob(u"Mob2").pos in [(1, 8), (3, 8)])
Пример #14
0
    def test_execute_move(self):
        class Fake:
            def up(self, dummy):
                self.up_set = True

            def down(self, dummy):
                self.down_set = True

            def left(self, dummy):
                self.left_set = True

            def right(self, dummy):
                self.right_set = True

        fb = Fake()
        gb = Gameboard(fb, [])
        gb.execute_movement((0, 0), u"up")
        assert (fb.up_set == True)
        fb = Fake()
        gb = Gameboard(fb, [])
        gb.execute_movement((0, 0), u"down")
        assert (fb.down_set == True)
        fb = Fake()
        gb = Gameboard(fb, [])
        gb.execute_movement((0, 0), u"left")
        assert (fb.left_set == True)
        fb = Fake()
        gb = Gameboard(fb, [])
        gb.execute_movement((0, 0), u"right")
        assert (fb.right_set == True)
Пример #15
0
 def test_move_illegal_player(self):
     gb = Gameboard(self._testboard, self._characters)
     gb.set_active_mob(u"Mob1", 10)
     assert (gb.move_mob(u"Mob2", u"down") == False)
Пример #16
0
 def test_enter_room(self):
     gb = Gameboard(self._testboard, self._characters)
     unoccupied_ones = [(2, 6), (3, 5), (3, 6)]
     gb.enter_room(u"Mob2", 1)
     assert (gb.get_mob(u"Mob2").pos in unoccupied_ones)