On Fri, Oct 3, 2008 at 8:50 AM, nathan virgil <[EMAIL PROTECTED]> wrote: > > > On Fri, Oct 3, 2008 at 9:19 AM, David <[EMAIL PROTECTED]> wrote: >> >> > Okay, I'm resurrecting this project. >> Where is this project code? > It seems like good code, It's not.
> # Content > # retrieve data for current room > room = 1 > if room == 1: this is always true because you just set room to 1 right before you checked the variable. > desc = "Ahead of you, you see a chasm." > ques = "Do you wish to try jumping over it? Y/N" > destYes = 2 > destNo = 3 > elif room == 2: this will never be true, which is why you can't get into the second room. This whole thing needs to be in a loop. But this is definitely not the best way to implement this either. > desc = "Ahead of you, you see a warty green ogre." > ques = "Do you wish to eat it? Y/N" > destYes = 4 > destNo = 5 > # etc for the rest of the rooms He's wiring these rooms together with numbers. The way I'd do it is to create a Room object with a bunch of different methods, such as room.print(), room.printDescription(), room.makeChoice(), and such, and then the rooms would be connected together using data members. It would be a lot more elegant and less confusing that way. > > # Engine > # ask current question and move to next room > print desc > ans = raw_input(ques).upper() # allow for lower case input > if ans == "Y": > room = destYes > elif ans == "N": > room = destNo > elif ans == "north": > room = destN > elif ans == "south": > room = destS > elif ans == "east": > room = destE > elif ans == "west": > room = destW > elif ans == "Q": # give us a way out. > Break > else: > print "I don't understand. Can you give a clearer answer?" You prompted the user, then retrieved the next room value. Now we're here, and there's no code left. So it stops here. > but for some reason, it's not letting me go into > Room 2 (the ogre). Is it clearer why this isn't working now? _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor