Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text Adventure
#2
(Sep-24-2016, 10:35 PM)Yelmos Wrote:
    displayIntro()
    choice = choosePath()
    checkPath(choice) # choice is equal to "1" or "2"
    choice = choosePath2()
    checkPath2(choice) # choice is equal to "1" or "2"
    choice = choosePath3()
    checkPath3(choice) # choice is equal to "1" or "2"
    choice = choosePath4()
    checkPath4(choice) # choice is equal to "1" or "2"
    displayMed()
    choice = choosePath5()
    checkPath5(choice) # choice is equal to "1" or "2" or "3"

What I would do is put this section of code into a function and create a custom exception. Then instead of calling sys.exit(), you can raise your GameFailed exception and catch it inside your while loop. There are some other ways to solve this problem, but this one requires the least refactoring.
Running Manjaro Linux 16.08/OpenRC/i3wm on a Dell Precision 5510.

John 3:17
Reply


Messages In This Thread
Text Adventure - by Yelmos - Sep-24-2016, 10:35 PM
RE: Text Adventure - by pydsigner - Sep-24-2016, 10:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Complete beginnner making a text based adventure Mishmaccles 2 2,673 Jul-07-2021, 05:00 PM
Last Post: BashBedlam
  Text Adventure Module Leroyrobenson 1 2,178 Feb-23-2020, 09:57 PM
Last Post: Larz60+
  Adding an inventory and a combat system to a text based adventure game detkitten 2 6,873 Dec-17-2019, 03:40 AM
Last Post: detkitten
  Advice for making a text choose your own adventure olivermcg 1 2,704 Apr-29-2019, 11:25 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020