I am trying to make a very simple branching story using a class, called Choices, and my main. Choices holds methods for each choice made, and each branch off has its own method, to keep things organized. My main evaluates the previous choice to decide what should run next. Everything returns; but the methods won't run when set to a variable! Everything I've looked at has been about more advanced programs; mine is a simple error that needs correcting. If anyone could tell me why, I'd be very grateful!
main.py:
import Choices
game = Choices.Choices()
reply = game.c()
if reply == "1":
reply = game.c1()
elif reply == "2":
reply = game.c2()
Choices.py:
class Choices:
answer = False
#Constructor
def __init__(self):
self.answer = False
#Initial Choice
def c(self):
while self.answer == False:
print "What would you like to do?" #Question
reply = input("[1] Wake up [2] Sleep in") #Answers
if reply == "1": #Choices
print "You get up." #Actions
self.answer = True
return reply
elif reply == "2": #Choices
print "You sleep more." #Actions
self.answer = True
return reply
else:
print "Not a choice."
self.answer = False
self.answer = False
#Branch 1
def c1(self):
while self.answer == False:
print "What would you like to do?" #Question
reply = input("[1] Make Breakfast [2] Get Dressed") #Answers
if reply == "1": #Choices
print "You go to the kitchen and make some oatmeal." #Actions
self.answer = True
return reply
elif reply == "2": #Choices
print "You go to the closet and put on some day clothes." #Actions
self.answer = True
return reply
else:
print "Not a choice."
self.answer = False
self.answer = False
#Branch 2
def c2(self):
while self.answer == False:
print "What would you like to do?" #Question
reply = input("[1] Wake up [2] Dream") #Answers
if reply == "1": #Choices
print "You get up." #Actions
self.answer = True
return reply
elif reply == "2": #Choices
print "You begin to dream. You are wandering in a forest, when you come to a crossroads..." #Actions
self.answer = True
return reply
else:
print "Not a choice."
self.answer = False
self.answer = False