Ensure that the neighboorhood is walkable in movement tests
This commit is contained in:
parent
3d7667573e
commit
895abe88ad
|
@ -12,6 +12,7 @@ from ..entities.items import Bomb, Heart, Sword
|
||||||
from ..entities.player import Player
|
from ..entities.player import Player
|
||||||
from ..enums import DisplayActions
|
from ..enums import DisplayActions
|
||||||
from ..game import Game, KeyValues, GameMode
|
from ..game import Game, KeyValues, GameMode
|
||||||
|
from ..interfaces import Tile
|
||||||
from ..menus import MainMenuValues
|
from ..menus import MainMenuValues
|
||||||
from ..resources import ResourceManager
|
from ..resources import ResourceManager
|
||||||
from ..settings import Settings
|
from ..settings import Settings
|
||||||
|
@ -204,6 +205,12 @@ class TestGame(unittest.TestCase):
|
||||||
self.game.map.remove_entity(entity)
|
self.game.map.remove_entity(entity)
|
||||||
|
|
||||||
y, x = self.game.player.y, self.game.player.x
|
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)
|
self.game.handle_key_pressed(KeyValues.DOWN)
|
||||||
new_y, new_x = self.game.player.y, self.game.player.x
|
new_y, new_x = self.game.player.y, self.game.player.x
|
||||||
self.assertEqual(new_y, y + 1)
|
self.assertEqual(new_y, y + 1)
|
||||||
|
|
Loading…
Reference in New Issue