I am trying to make a simple game.
The logic is like this: "There are five doors, each numbered 1 to 5. Users will be asked to input any one number. For example, if they enter "1", the GoldRoom will be opened (and the associated class will be processed)."
Now, I have defined one class, GoldRoom(), and for testing, entered "1". The processing happens as expected. However, when I enter "2" as my choice, the processing still happens, instead of the print statement, i.e the else statement is not getting executed.
Where am I going wrong?
#################################
# 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 "Enter your choice:"
room_chosen = int(raw_input("> "))
if room_chosen == 1:
goldroom = GoldRoom()
goldroom.gold_room()
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):
# 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("> ")
if "0" in next or "1" in next:
how_much = int(next)
print how_much
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
#class Cthulhu_Room(Room):
# sort of puzzle to get out
#class Bear_Room(Room):
# bear room
#class Dark_Room(Room):
# Dark Room, will be turned into Zombie
#class Dead_Room(Room):
# Those who enter here would be dead
if room_chosen == 1:
goldroom = GoldRoom()
goldroom.gold_room()
else:
print "YOU SUCK!"