Add routine to play until last action
This commit is contained in:
@@ -127,6 +127,15 @@ class Gameplay():
|
||||
raise CannotChangeThePastException
|
||||
|
||||
|
||||
def _get_last_action_time(self):
|
||||
try:
|
||||
last_action_time = max(self.actions.keys())
|
||||
except ValueError:
|
||||
last_action_time = self.world.current_time
|
||||
|
||||
return last_action_time
|
||||
|
||||
|
||||
def _get_next_action_time(self):
|
||||
try:
|
||||
next_action_time = min(self.actions.keys())
|
||||
@@ -159,6 +168,11 @@ class Gameplay():
|
||||
self._handle_actions()
|
||||
|
||||
|
||||
def play_until_last_action(self, extra_time=0):
|
||||
last_action_time = self._get_last_action_time()
|
||||
self.play_until(last_action_time + extra_time)
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.world = World()
|
||||
self.actions = defaultdict(list)
|
||||
|
||||
Reference in New Issue
Block a user