Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

Commit

Permalink
add redo command
Browse files Browse the repository at this point in the history
  • Loading branch information
ifdog committed Feb 12, 2020
1 parent 591f318 commit 7c25167
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions play.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,23 @@ def play_aidungeon_2(args):
console_print(story_manager.story.story_start)
continue

elif command == "redo":
if len(story_manager.story.actions) == 0:
console_print("You can't redo. ")
continue
last_action = story_manager.story.actions[-1]
story_manager.story.actions = story_manager.story.actions[:-1]
story_manager.story.results = story_manager.story.results[:-1]
if len(story_manager.story.results) > 0:
console_print(story_manager.story.results[-1])
else:
console_print(story_manager.story.story_start)
console_print("Redo last action: ")
console_print(last_action)
result = story_manager.act(action)
console_print(result)
continue

else:
console_print("Unknown command: {}".format(command))

Expand Down

1 comment on commit 7c25167

@OrionFive
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful! Could you also add "retry" as an alternative? To me retry feels more fitting, so having both might be useful.

Please sign in to comment.