-
Notifications
You must be signed in to change notification settings - Fork 0
/
memento.py
49 lines (39 loc) · 1.3 KB
/
memento.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# from board import Board
# class TurnMemento:
# def __init__(self, turn_log):
# self._turn = turn_log
# def get_turn(self):
# return self._turn
# class Caretaker():
# """
# Manages the TurnMementos
# """
# def __init__(self, board:Board):
# self._future = [] # redo
# self._history = [] # undo
# self._board = board
# def save(self, turn_memento):
# """
# Saves a turn log containing:
# (worker, move_space, build_space, was_space)
# """
# # Empty out redo list whenever player takes turn
# self._future = []
# self._history.append(turn_memento)
# def undo(self):
# # check if there are past moves (WIP DO WE NEED TO DO SOMETHING WHEN UNDO NOT POSSIBLE?)
# if len(self._history) == 0:
# return False
# memento = self._history.pop()
# # Add to future list for redos
# self._future.append(memento)
# self._board.undo_turn(memento)
# return True
# def redo(self):
# if len(self._future) == 0:
# return False
# memento = self._future.pop()
# # Re-add to history list for re-undos
# self._history.append(memento)
# self._board.redo_turn(memento)
# return True