add Observer and Command
This commit is contained in:
parent
29495a0eda
commit
056c905032
0
pomelovsd/ExitMaze/Observer|Command/Command.py
Normal file
0
pomelovsd/ExitMaze/Observer|Command/Command.py
Normal file
0
pomelovsd/ExitMaze/Observer|Command/ConsoleView.py
Normal file
0
pomelovsd/ExitMaze/Observer|Command/ConsoleView.py
Normal file
15
pomelovsd/ExitMaze/Observer|Command/MoveCommand.py
Normal file
15
pomelovsd/ExitMaze/Observer|Command/MoveCommand.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
from Command import Command
|
||||||
|
|
||||||
|
class MoveCommand(Command):
|
||||||
|
|
||||||
|
def __init__(self, player, target):
|
||||||
|
self.player = player
|
||||||
|
self.target = target
|
||||||
|
self.previous = None
|
||||||
|
|
||||||
|
def execute(self):
|
||||||
|
self.previous = self.player.current
|
||||||
|
self.player.current = self.target
|
||||||
|
|
||||||
|
def undo(self):
|
||||||
|
self.player.current = self.previous
|
||||||
0
pomelovsd/ExitMaze/Observer|Command/Observer.py
Normal file
0
pomelovsd/ExitMaze/Observer|Command/Observer.py
Normal file
Loading…
Reference in New Issue
Block a user