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)