Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ex45_dialogue
- class LifeQuality(object):
- def __init__(self):
- self.adjectives = ['no', 'some', 'plenty of', 'a lot of', 'tons of',
- 'countless amount of']
- def counter(self, index):
- return self.adjectives[index]
- class Engine(object):
- def __init__(self, scene_map):
- self.scene_map = scene_map
- # self.decision = decision
- def play(self):
- current_scene = self.scene_map.opening_scene()
- last_scene = self.scene_map.next_scene('Finished')
- # current_decision = self.decision.next_decision('Witch')
- while current_scene != last_scene:
- # next_scene_name = current_scene.enter(current_decision)
- next_scene_name = current_scene.enter()
- # current_decision = self.decision.next_decision(next_scene_name)
- current_scene = self.scene_map.next_scene(next_scene_name)
- current_scene.enter()
- #class Action(object):
- # def Life_or_Lose(self, scene):
- # if scene == 'witch':
- # print 'you may enter'
- # scene_actions = {
- # 'Witch': Life_or_Lose('witch'),
- # 'Copper_Room': 'Copper_Room()',
- # 'Silver_Room': "move the cat and take as much silver as you can.",
- # 'Gold_Room': "move the three magical dogs and take as much gold as you can",
- # 'Life': "whatchu gon do?",
- # 'Hanging': "what's your final request?",
- # 'Lose': "dead up",
- # 'Finished': "you win."
- # }
- # def __init__(self):
- # pass
- # def next_decision(self, scene):
- # val = Action.scene_actions.get(scene)
- # return val
- class Scene(object):
- def enter(self):
- pass
- class Witch(Scene):
- def enter(self):
- print
- print "*" * 20
- print ex45_dialogue.witch_opener
- response = raw_input("Yes or No?\n\t>")
- ## insert a loop here to ask again if response == 'No'
- attempts = 0
- while response != 'Yes':
- if attempts == 0:
- print "'No?' You can be richer than you ever imagined."
- elif attempts == 1:
- print "Are you sure? This is your last chance"
- else:
- print "'Fuck this dealer.' he says and continues home."
- return 'Lose'
- attempts +=1
- response = raw_input("Yes or No?\n\t>")
- print ex45_dialogue.witch_response
- return 'Copper_Room'
- class CopperRoom(Scene):
- def enter(self):
- print
- print "*" * 20
- print ex45_dialogue.copperroom_opener
- response = raw_input("What do you want to do?\n\t>")
- ## insert a loop here to ask again if response == 'mouse'
- attempts = 0
- while not 'mouse' in response:
- if attempts == 0:
- print "'{}' didn't work. Try something else.".format(response)
- elif attempts == 1:
- print "'{}' doesn't work either. Hmmmm.".format(response)
- else:
- print "'Fuck this dealer.' he says and continues home."
- return 'Lose'
- attempts +=1
- response = raw_input("What do you want to do?\n\t>")
- print ex45_dialogue.copperroom_response
- return 'Silver_Room'
- class SilverRoom(Scene):
- def enter(self):
- print
- print "*" * 20
- print ex45_dialogue.silverroom_opener
- ## insert a loop here to ask again if response == 'cat'
- response = raw_input("What do you do?\n\t>")
- attempts = 0
- while not 'cat' in response:
- if attempts == 0:
- print "'{}' didn't work. Try something else.".format(response)
- elif attempts == 1:
- print "'{}' doesn't work either. Hmmmm.".format(response)
- else:
- print "'Fuck this dealer.' he says and continues home."
- return 'Lose'
- attempts +=1
- response = raw_input("What do you want to do?\n\t>")
- print ex45_dialogue.silverroom_response
- return 'Gold_Room'
- class GoldRoom(Scene):
- def enter(self):
- print
- print "*" * 20
- print ex45_dialogue.goldroom_opener
- response = raw_input("What do you do?\n\t>")
- attempts = 0
- while not 'dog' in response:
- if attempts == 0:
- print "'{}' didn't work. Try something else.".format(response)
- elif attempts == 1:
- print "'{}' doesn't work either. Hmmmm.".format(response)
- else:
- print "'Fuck this dealer.' he says and continues home."
- return 'Lose'
- attempts +=1
- response = raw_input("What do you want to do?\n\t>")
- print ex45_dialogue.goldroom_response
- return 'Life'
- class Life(Scene):
- def enter(self):
- print
- print "*" * 20
- print ex45_dialogue.life_opener
- ## create condition that counts loops
- ## after 2 loops introduce knowledge of princess
- ## as non-dog responses increase, get better adjectives for returns
- ## if non-dog respones = 5 make money == 0
- ## dogs can get more money
- ## dogs can get princess
- ## use a keyword list to customize returns.
- counter = 0
- dogs = False
- princess = False
- while not princess:
- money = LifeQuality()
- money_index = max(0, min(5-counter, 5))
- print 'money_index, ',money_index
- money_amt = money.counter(money_index)
- friends = LifeQuality()
- friends_index = max(0, min(0 + counter, 5))
- print 'friends_index, ',friends_index
- friends_amt = friends.counter(friends_index)
- response = raw_input("What does the young soldier do?\n\t>")
- counter += 1
- if any(word in response for word in ['dog','tinderbox']) :
- print "The dogs from the Gold Room appear."
- dogs = True
- elif dogs and (word in response for word in ['money', 'coin', 'treasure']):
- print "The dogs go to the rooms with the treasure chests and bring back gold"
- elif 'princess' in response and dogs:
- print "The dogs go to the tower where the princess is being held and bring her to you."
- princess = True
- elif 'princess' in response and not dogs:
- print "How? She's in the unreachable tower."
- else:
- if money_amt != 'no':
- print "The soldier goes hard."
- print "He {}. He's living life.".format(response)
- else:
- print "He can't {} anymore. He's broke".format(response)
- print "He's got {} friends and {} money".format(friends_amt, money_amt)
- # while True:
- # response = raw_input("What do you do?\n\t>" )
- # if 'buy' in response:
- # print Life.buy[buy_count]
- # buy_count += 1
- # elif 'girl' in response:
- # print Life.girl[girl_count]
- # girl_count += 1
- # elif 'dogs' in response:
- # print 'The magical dogs arrive. They await your orders.'
- # dogs = True
- # elif 'princess' in response and dogs == False:
- # print "You don't know how to get to her yet."
- # elif 'princess' in response and dogs == True:
- # print "The dogs bring you the princess from her tower."
- # break
- # else:
- # print "I don't know what '{}' is but I ain't balling like you.".format(response)
- return 'Hanging'
- class Hanging(Scene):
- def enter(self):
- print
- print "*" * 20
- print ex45_dialogue.hanging_opener
- response = raw_input("What would is your final wish?\n\t")
- if 'smoke' or 'cigarette' in response:
- print """
- The king agrees. He uses your tinder box and unknowingly summons the magical
- dogs. They kill the king and queen. The crowd is frightened and release you to
- spare their lives.
- """
- return 'Finished'
- else:
- print "They allow you to {}. You savour your final moment of freedom."
- return 'Lose'
- class Lose(Scene):
- def enter(self):
- print
- print "*" * 20
- print "Dead up.\n\n The end."
- exit(0)
- class Finished(Scene):
- def enter(self):
- print
- print "*" * 20
- print "You marry the princess. You become king. You win.\n\n The end."
- exit (0)
- class Map(object):
- scenes = {
- 'Witch': Witch(),
- 'Copper_Room': CopperRoom(),
- 'Silver_Room': SilverRoom(),
- 'Gold_Room': GoldRoom(),
- 'Life': Life(),
- 'Hanging': Hanging(),
- 'Lose': Lose(),
- 'Finished': Finished()
- }
- def __init__(self, start_scene):
- self.start_scene = start_scene
- def next_scene(self, scene_name):
- val = Map.scenes.get(scene_name)
- return val
- def opening_scene(self):
- return self.next_scene(self.start_scene)
- #a_action = Action()
- a_map = Map('Witch')
- a_game = Engine(a_map)
- a_game.play()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement