Skip to content

Commit

Permalink
Added ratings to win and death
Browse files Browse the repository at this point in the history
  • Loading branch information
LaTueur committed Dec 18, 2019
1 parent dc49be8 commit 7c907a1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
22 changes: 4 additions & 18 deletions play.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,27 +221,11 @@ def play_aidungeon_2():
command = split[0].lower()
args = split[1:]
if command == "restart":
while True:
try:
rating = input("Please rate the story quality from 1-10: ")
rating_float = max(min(float(rating), 10), 1)
except ValueError:
print("Please return a valid number.")
else:
story_manager.story.rating = rating_float
break
story_manager.story.get_rating()
break

elif command == "quit":
while True:
try:
rating = input("Please rate the story quality from 1-10: ")
rating_float = max(min(float(rating), 10), 1)
except ValueError:
print("Please return a valid number.")
else:
story_manager.story.rating = rating_float
break
story_manager.story.get_rating()
exit()

elif command == "nosaving":
Expand Down Expand Up @@ -353,6 +337,7 @@ def play_aidungeon_2():

if player_won(result):
console_print(result + "\n CONGRATS YOU WIN")
story_manager.story.get_rating()
break
elif player_died(result):
console_print(result)
Expand All @@ -365,6 +350,7 @@ def play_aidungeon_2():
console_print("Which do you choose? ")
choice = get_num_options(2)
if choice == 0:
story_manager.story.get_rating()
break
else:
console_print("Sorry about that...where were we?")
Expand Down
11 changes: 11 additions & 0 deletions story/story_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ def load_from_storage(self, story_id):
else:
return "Error save not found."

def get_rating(self):
while True:
try:
rating = input("Please rate the story quality from 1-10: ")
rating_float = max(min(float(rating), 10), 1)
except ValueError:
print("Please return a valid number.")
else:
self.rating = rating_float
return


class StoryManager:
def __init__(self, generator):
Expand Down

0 comments on commit 7c907a1

Please sign in to comment.