I was looking at someone's code asked a year about having trouble with making a game and I came across a question about another part of their code that I cannot figure out. The following is the code...
game_runner.py
from game_map import *
class Runner(object):
def __init__(self, start):
self.start = start
def play(self):
next_room = self.start
while True:
print '\n'
print '-' * 7
print next_room.__doc__
next_room.proceed()
firstroom = Chillin()
my_game = Runner(firstroom)
my_game.play()
game_map.py
from sys import exit
class Chillin(object):
"""It's 8pm on a Friday night in Madison. You're lounging on the couch with your
roommates watching Dazed and Confused. What is your first drink?
1. beer
2. whiskey
3. vodka
4. bowl
"""
def __init__(self):
self.prompt = '> '
def proceed(self):
drink = raw_input(self.prompt)
if drink == '1' or drink == 'beer':
print '\n Anytime is the right time.'
print 'You crack open the first beer and sip it down.'
room = Pregame()
return room
#rest of drinks will be written the same way
class Pregame(object):
"""It's time to really step up your pregame.
How many drinks do you take?
"""
def proceed(self):
drinks = raw_input('> ')
#and so on
So my question here is when firstroom = Chillin()
the def __init__
is called, but somehow the self.prompt = '> '
doesn't show up until after the While loop loops through once. I am still quite new to coding so this question may seem vague but hopefully someone can answer because I am very confused. Thanks!