Ensure that the neighboorhood is walkable in movement tests

This commit is contained in:
Yohann D'ANELLO 2020-12-11 19:14:25 +01:00
parent 3d7667573e
commit 895abe88ad

View File

@ -12,6 +12,7 @@ from ..entities.items import Bomb, Heart, Sword
from ..entities.player import Player
from ..enums import DisplayActions
from ..game import Game, KeyValues, GameMode
from ..interfaces import Tile
from ..menus import MainMenuValues
from ..resources import ResourceManager
from ..settings import Settings
@ -204,6 +205,12 @@ class TestGame(unittest.TestCase):
self.game.map.remove_entity(entity)
y, x = self.game.player.y, self.game.player.x
# Ensure that the neighborhood is walkable
for dx in [-1, 0, 1]:
for dy in [-1, 0, 1]:
self.game.map.tiles[y + dy][x + dx] = Tile.FLOOR
self.game.handle_key_pressed(KeyValues.DOWN)
new_y, new_x = self.game.player.y, self.game.player.x
self.assertEqual(new_y, y + 1)