2026-rff_mp/BrychkinKA/src/ui/move_command.py
2026-05-25 15:23:54 +03:00

17 lines
477 B
Python

from src.model.cell import Cell
from .command import Command
from .player import Player
class MoveCommand(Command):
def __init__(self, player: Player, new_cell: Cell):
self.player = player
self.new_cell = new_cell
self.prev_cell = None
def execute(self):
self.prev_cell = self.player.current_cell
self.player.move_to(self.new_cell)
def undo(self):
if self.prev_cell:
self.player.move_to(self.prev_cell)