#################################
# Learning to make a game #
#################################
# An attempt to make a game
# Each room will be described by a class, whose base class will be Room
# The user will be prompted to enter a number, each number will be assigned with a Room in return
from sys import exit
print '-' * 50
print "You are a lone traveller on this earth"
print "who is just roaming and roaming."
print "finally you encounter 5 doors."
print "Each door has some stuff in store for you except one,"
print "which has death in store for you."
print "So choose your doors with cool mind."
print '-' * 50
print "Enter your choice:",
room_chosen = int(raw_input("[keypad]>"))
def dead(why):
print "why, Good Job!"
exit(0)
#class Room(object): #the other room will be derived of this
# pass
class Room(object):
pass
class GoldRoom(Room):
def gold_room(self):
# here the user will be asked with question on how much Gold he wants
print"This room is full of gold. How much do you take!"
next = raw_input("[keypad]>")
print next
if next.isdigit():
how_much = int(next)
else:
dead("Man, learn to type some number")
if how_much < 50:
print "Nice, you are not greedy, you win!"
exit(0)
else:
dead("You greedy bastard!")
class KoiPondRoom(Room):
# in this room, the user will be made to relax
def koi_pond_room(self):
print "You have entered a room where you can relaz!"
next = raw_input("> ")
if next == "Sleeping":
print "SLEEP WELL!"
elif next == "Television Watching":
print "WOHOO! WATCH AMAZING SPIDERMAN!"
elif next == "EATING":
print "COOL! NPOW HOG!"
else:
print "GO TO HELL!"
class Cthulhu_Room(Room):
# sort of puzzle to get out
def cthulhu_room(self):
print "Here's how see the great evil Cthulhu"
print "He,it, whatever stares at you and you go insane."
print "Do you flee for your life or eat your head?"
next = raw_input("> ")
if "flee" in next:
goldroom = GoldRoom()
goldroom.gold_room()
elif "head" in next:
dead("Well, that was tasty!")
else:
cthulhu_room = Cthulhu_Room()
cthulhu_room.cthulhu_room()
class Bear_Room(Room):
# bear room
def bear_room(self):
print "There's a bear here"
print "The bear has a bunch of honey."
print "The fat bear is in front of another door."
print "How are you going to move the bear."
bear_moved = False
while True:
next = raw_input("> ")
if next == "take honey":
dead("The bear looks at you and then slaps your face off.")
elif next == "taunt bear" and not bear_moved:
print "The bear has moved from the door. You can go through it now."
bear_moved = True
elif next == "taunt bear" and bear_moved:
dead("The bear gets pissed off and chews your leg.")
elif next == "open door" and bear_moved:
goldroom = GoldRoom()
goldroom.gold_room()
else:
print "I got no idea what it means."
class Dark_Room(Room):
def dark_room(self):
print "You have entered a dark room."
print "If you want to escape, then guess the correct password!"
print "But you have only three chances,"
print "failing which you will be locked here forever."
password = str ("OPEN SEASAME")
guess = raw_input("Enter password:>")
guesses = 0
while guess != password and guesses < 2:
print "Try again!"
guesses += 1
guess = raw_input("Enter password:>")
if guess == password:
print "You have made it!"
else:
print "YOU HAVE BEEN LOCKED HERE FOREVER,"
print "NOW SUFFER"
class Dead_Room(Room):
def dead_room(self):
print "You MORON!"
print "why did you chose this?"
print "you are DEAD now"
if room_chosen == 1:
goldroom = GoldRoom()
goldroom.gold_room()
elif room_chosen == 2:
koipondroom = KoiPondRoom()
koipondroom.koi_pond_room()
elif room_chosen == 3:
cthulhu_room = Cthulhu_Room()
cthulhu_room.cthulhu_room()
elif room_chosen == 4:
bear_room = Bear_Room()
bear_room.bear_room()
elif room_chosen == 5:
dark_room = Dark_Room()
dark_room.dark_room()
elif room_chosen == 6:
dead_room = Dead_Room()
dead_room.dead_room()
else:
print "YOU SUCK!"
peterparker 0 Light Poster
peterparker 0 Light Poster
TrustyTony 888 pyMod Team Colleague Featured Poster
peterparker 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.