From 95dd862d49e11814c2b350c7283c51f8917777fd Mon Sep 17 00:00:00 2001 From: komissarovgo Date: Sun, 17 May 2026 14:48:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=8B=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=83=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- komissarovgo/docs2/data2/maze_lab/commands.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 komissarovgo/docs2/data2/maze_lab/commands.py diff --git a/komissarovgo/docs2/data2/maze_lab/commands.py b/komissarovgo/docs2/data2/maze_lab/commands.py new file mode 100644 index 0000000..c915130 --- /dev/null +++ b/komissarovgo/docs2/data2/maze_lab/commands.py @@ -0,0 +1,27 @@ +from abc import ABC, abstractmethod +from models import Cell, Player + + +class Command(ABC): + + @abstractmethod + def execute(self) -> None: + pass + + @abstractmethod + def undo(self) -> None: + pass + + +class MoveCommand(Command): + + def __init__(self, player: Player, new_cell: Cell): + self._player = player + self._new_cell = new_cell + self._old_cell = player.current_cell + + def execute(self) -> None: + self._player.move_to(self._new_cell) + + def undo(self) -> None: + self._player.move_to(self._old_cell) \ No newline at end of file