Collisions are working
This commit is contained in:
		@@ -5,14 +5,14 @@ class Player(FightingEntity):
 | 
				
			|||||||
    maxhealth = 20
 | 
					    maxhealth = 20
 | 
				
			||||||
    strength = 5
 | 
					    strength = 5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def move_up(self) -> None:
 | 
					    def move_up(self) -> bool:
 | 
				
			||||||
        self.check_move(self.y - 1, self.x, True)
 | 
					        return self.check_move(self.y - 1, self.x, True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def move_down(self) -> None:
 | 
					    def move_down(self) -> bool:
 | 
				
			||||||
        self.check_move(self.y + 1, self.x, True)
 | 
					        return self.check_move(self.y + 1, self.x, True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def move_left(self) -> None:
 | 
					    def move_left(self) -> bool:
 | 
				
			||||||
        self.check_move(self.y, self.x - 1, True)
 | 
					        return self.check_move(self.y, self.x - 1, True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def move_right(self) -> None:
 | 
					    def move_right(self) -> bool:
 | 
				
			||||||
        self.check_move(self.y, self.x + 1, True)
 | 
					        return self.check_move(self.y, self.x + 1, True)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -76,6 +76,22 @@ class TestEntities(unittest.TestCase):
 | 
				
			|||||||
        Test some random stuff with players.
 | 
					        Test some random stuff with players.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        player = Player()
 | 
					        player = Player()
 | 
				
			||||||
 | 
					        self.map.add_entity(player)
 | 
				
			||||||
 | 
					        player.move(1, 6)
 | 
				
			||||||
        self.assertEqual(player.strength, 5)
 | 
					        self.assertEqual(player.strength, 5)
 | 
				
			||||||
        self.assertEqual(player.health, player.maxhealth)
 | 
					        self.assertEqual(player.health, player.maxhealth)
 | 
				
			||||||
        self.assertEqual(player.maxhealth, 20)
 | 
					        self.assertEqual(player.maxhealth, 20)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # Test movements and ensure that collisions are working
 | 
				
			||||||
 | 
					        self.assertFalse(player.move_up())
 | 
				
			||||||
 | 
					        self.assertTrue(player.move_left())
 | 
				
			||||||
 | 
					        self.assertFalse(player.move_left())
 | 
				
			||||||
 | 
					        for i in range(8):
 | 
				
			||||||
 | 
					            self.assertTrue(player.move_down())
 | 
				
			||||||
 | 
					        self.assertFalse(player.move_down())
 | 
				
			||||||
 | 
					        self.assertTrue(player.move_right())
 | 
				
			||||||
 | 
					        self.assertTrue(player.move_right())
 | 
				
			||||||
 | 
					        self.assertTrue(player.move_right())
 | 
				
			||||||
 | 
					        self.assertFalse(player.move_right())
 | 
				
			||||||
 | 
					        self.assertTrue(player.move_down())
 | 
				
			||||||
 | 
					        self.assertTrue(player.move_down())
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user