Player move delay
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from hopper.enums import Direction, PlayerMoveResult
|
||||
@ -68,8 +69,6 @@ class GameEngine:
|
||||
new_position = Position(player.position.x, player.position.y)
|
||||
logging.info(f"Player {player} move to {direction}")
|
||||
|
||||
player.move_attempt_count += 1
|
||||
|
||||
if direction == Direction.LEFT:
|
||||
new_position.x -= 1
|
||||
elif direction == Direction.RIGHT:
|
||||
@ -81,6 +80,8 @@ class GameEngine:
|
||||
else:
|
||||
raise ValueError(f"Unhandled direction: {direction}")
|
||||
|
||||
player.move_attempt_count += 1
|
||||
|
||||
if not self.position_in_board_bounds(new_position):
|
||||
raise PositionOutOfBounds()
|
||||
|
||||
@ -97,6 +98,8 @@ class GameEngine:
|
||||
return PlayerMoveResult.DESTINATION_REACHED
|
||||
|
||||
self.__debug_print_board()
|
||||
|
||||
await asyncio.sleep(settings.game.MOVE_DELAY)
|
||||
return PlayerMoveResult.OK
|
||||
|
||||
def is_player_on_destination(self, player: Player) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user