Help me play-test my text adventure? (beginner)

Reply

Join Date: Jul 2008
Posts: 6
Reputation: k.wiseman is an unknown quantity at this point 
Solved Threads: 0
k.wiseman k.wiseman is offline Offline
Newbie Poster

Help me play-test my text adventure?

 
0
  #1
Jul 2nd, 2008
Hi!

I just started poking around with Python recently, and I decided to do a text-adventure game project to practice some of the core concepts. Trying to think of ways to go about it, I stumbled on this DaniWeb post:

http://www.daniweb.com/forums/thread...t+rpg+tutorial

Gave me a lot of inspiration, and I took my main layout from that. Wonderful practice! So thanks to everyone who contributed to that thread. Hope you don't mind I borrowed some pieces of the code skeleton from there.

In any case, I'm about done with the adventure, but there are some minor (So far non-fatal) problems I've run into. The game is mostly playable, unless it has some errors I don't know about, which is more than likely.

I've sorted out most of the problems I've run into myself, but one thing I can't figure out is:
The "quit" option works just fine in the first few rooms. Then it starts screwing up a bit, looping once before quitting. I can't figure out where it starts to go screwy, except that it always messes up after you've entered the Fungal Garden. Seems like that's not always the case, though.

The looping becomes increasingly worse with each new room you go into when you try to quit from there. For example, if you try to quit in the sept, "Press Enter to Quit" loops once, but you can still quit. If you try to quit in, say, the last room of the game, you get an infinite loop.

I've been over the whole thing again and again, but I just can't find what the problem is.

I hope you guys will be willing to play-test / help me debug!

Any other comments on the code, suggestions on things to add or take out, and general advice would be greatly appreciated. Thanks!

Code can be found here: http://www.mediafire.com/?xfn1ngn1gdp

(Attempted) features include:
1) Linked puzzles and brain-teasers
2) Two tricky insta-kills
3) Exciting sorta-combat!
4) A womanizing, alcoholic protagonist
5) 11 rooms

Thanks for your help and patience.

Kendra
Last edited by k.wiseman; Jul 2nd, 2008 at 2:07 pm. Reason: Grammatical error, added more to post
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 6
Reputation: k.wiseman is an unknown quantity at this point 
Solved Threads: 0
k.wiseman k.wiseman is offline Offline
Newbie Poster

Re: Help me play-test my text adventure? (beginner)

 
0
  #2
Jul 2nd, 2008
Blarg. Just found an error myself.

After you re-enter the bedroom, the exit directions disappear. They should read:

"You see exits leading (E)ast, (W)est and (S)outh."
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: Help me play-test my text adventure? (beginner)

 
0
  #3
Jul 2nd, 2008
It looks very nice. I guess I only have one comment at the moment, and that is that printing multiple lines of text is easier if you use triple quotes instead of lots of different print statements. For example:
  1. print "You press one hand to your eyes and wave him away, but Ferrontius doe
  2. s"
  3. print "not move to go. 'I'm sorry, my liege, but it's my duty to inform"
  4. print "you that you've been confined to your apartments. Your father's order
  5. s,"
  6. print "I'm afraid.'"
  7. print
->
  1. print """\
  2. You press one hand to your eyes and wave him away, but Ferrontius does
  3. not move to go. 'I'm sorry, my liege, but it's my duty to inform
  4. you that you've been confined to your apartments. Your father's orders,
  5. I'm afraid.'
  6. """
Just a thought. You could also read the descriptions from files, I guess, but that's not really necessary.

Good work, it's much more than I'd have the patience to do.
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 6
Reputation: k.wiseman is an unknown quantity at this point 
Solved Threads: 0
k.wiseman k.wiseman is offline Offline
Newbie Poster

Re: Help me play-test my text adventure? (beginner)

 
0
  #4
Jul 3rd, 2008
Thanks! I have the not-so-sneaking suspicion that the code could have been about half as long if I knew a little more.

For example, the prompts for every room are similar, but not the same. Anyone have any idea how I could have made a "prompt" class?

For example
First room:

  1. Leogas' bedroom
  2. def bedroom():
  3. global leogasHp
  4. print "Health: ", leogasHp
  5. if leogasLeftBedroom == 0:
  6. bed_Desc1()
  7. else:
  8. bed_Desc2()
  9.  
  10. # If you haven't left the room yet, this description will trigger
  11. def bed_Desc1():
  12. print "You are standing in your own bedroom. In the corner is a preposterously"
  13. print "large, opulent four-poster bed. Empty wine bottles litter the floor and"
  14. print "the top of the dresser. Discarded clothing lays strewn about the rich"
  15. print "quarters. A faint, directionless light permeates the room."
  16. print "You see exits leading (E)ast, (W)est and (S)outh."
  17. print "Type 'help' for a list of commands."
  18. print
  19. prompt_bed()
  20.  
  21. # If you've already left the room, and are coming back, this description will trigger
  22. def bed_Desc2():
  23. print "You are standing in your own bedroom. While you were out, it seems the"
  24. print "servants have inconspicuosly tidied up. Your bed was painstakingly made, "
  25. print "and the floors and surfaces are free of clutter. Seems the maids aren't perfect,"
  26. print "however, as one last bottle lays half-hidden beneath the bed. A faint,"
  27. print "directionless light permeates the room."
  28. print "You see exits leading (E)ast, (W)est and (S)outh."
  29. print "Type 'help' for a list of commands."
  30. print
  31. prompt_bed()
  32.  
  33. #prompt for bedroom
  34. def prompt_bed():
  35. global leogasLeftBedroom
  36. global inventory
  37. prompt_b = raw_input("Your orders, my liege? ").lower()
  38. try:
  39. if prompt_b == "e":
  40. leogasLeftBedroom = 1
  41. library()
  42. elif prompt_b == "w":
  43. leogasLeftBedroom = 1
  44. guardroom()
  45. elif prompt_b == "s":
  46. leogasLeftBedroom = 1
  47. fungalGarden()
  48. elif prompt_b == "help":
  49. help1()
  50. prompt_bed()
  51. elif prompt_b == "look":
  52. if leogasLeftBedroom == 0:
  53. bed_Desc1()
  54. else:
  55. bed_Desc2()
  56. elif prompt_b == "ex bed":
  57. if leogasLeftBedroom == 0:
  58. print "Your bed is a gigantic mess of slept-in silks and satins. Is that a"
  59. print "splash of vomit you see on the brocade pillows?"
  60. else:
  61. print "Your voluminous bed, with its carved mahogany posts, has been"
  62. print "meticulously made."
  63. print
  64. prompt_bed()
  65.  
  66. #You get a potion later. This ensures you can drink it while in the bedroom.
  67.  
  68. elif prompt_b == "drink potion" or prompt_b == "drink healing potion":
  69. if "a healing potion" in inventory:
  70. if leogasHp < 35:
  71. leogasHp = 35
  72. print "You've been healed! Your health is now ", leogasHp
  73. inventory.remove("a healing potion")
  74. else:
  75. print "You really ought to save that for when it counts."
  76. print
  77. prompt_bed()
  78. else:
  79. print "You don't have a healing potion."
  80. print
  81. prompt_bed()
  82. elif prompt_b == "ex clothes":
  83. if leogasLeftBedroom == 0:
  84. print "Your fine clothes lay rumpled in scattered heaps across the room. They"
  85. print "smell like pipe smoke and are splotched with stains."
  86. else:
  87. print "Your clothes are hanging neatly in the closet."
  88. print
  89. prompt_bed()
  90. elif prompt_b == "ex bottles" or prompt_b == "ex bottle" or prompt_b == "ex wine":
  91. if leogasLeftBedroom == 0:
  92. print "Countless wine bottles of every shape and size lay around the room."
  93. print "Their emptiness is the only thing they have in common."
  94. else:
  95. print "The maids cleaned out all the bottles, except one, which you see poking"
  96. print "out from beneath the bed."
  97. print
  98. prompt_bed()
  99. elif prompt_b == "take bottles" or prompt_b == "take bottle" or prompt_b == "take wine":
  100. if "an empty wine bottle" in inventory:
  101. print "You're already carrying a wine bottle."
  102. else:
  103. print "You snatch up an empty bottle. Its pleasing heft comforts you."
  104. inventory += ["an empty wine bottle"]
  105. print "Your inventory now contains: "
  106. for item in inventory:
  107. print item
  108. print
  109. prompt_bed()
  110. elif prompt_b == "take bed":
  111. print "It's much too heavy, and anyway, you're in a weakened state."
  112. print
  113. prompt_bed()
  114. elif prompt_b == "ex dresser":
  115. print "This stunning dresser features ironwork handles and a stunning walnut finish."
  116. print
  117. prompt_bed()
  118. elif prompt_b == "open dresser":
  119. print "It's full of dresses. Always wondered why they called it that."
  120. print
  121. prompt_bed()
  122. elif prompt_b == "take dresser":
  123. print "An adventurous spirit is appreciated, but c'mon."
  124. print
  125. prompt_bed()
  126. elif prompt_b == "take dresses":
  127. print "Oh, how the servants would talk."
  128. print
  129. prompt_bed()
  130. elif prompt_b == "take clothes":
  131. print "You ought to wait until the Clean Clothes Fairy comes and washes them, don't"
  132. print "you think?"
  133. print
  134. prompt_bed()
  135. elif prompt_b == "ex pillow" or prompt_b == "ex pillows":
  136. print "The pillows are crafted from the finest red velvet and exquisite brocade."
  137. print "They smell of last night's dinner."
  138. print
  139. prompt_bed()
  140. elif prompt_b == "take pillow" or prompt_b == "take pillows":
  141. print "Pillow fights are for sissies. Or for sultry bar wenches in lingerie."
  142. print "You are neither."
  143. print
  144. prompt_bed()
  145. elif prompt_b == "i":
  146. print "Your inventory contains: "
  147. for item in inventory:
  148. print item
  149. print
  150. prompt_bed()
  151.  
  152. #you get a spotted mushroom later in the game. If you eat it at any time, you die. This ensures you can eat it in the bedroom.
  153.  
  154. elif prompt_b == "eat mushroom" or prompt_b == "eat mushrooms":
  155. if "a spotted mushroom" in inventory:
  156. print "Colors and lights start to swirl before your eyes. You feel a portal"
  157. print "to another world opening."
  158. die()
  159. else:
  160. print "You don't have a spotted mushroom."
  161. print
  162. prompt_bed()
  163. elif prompt_b == "q":
  164. quit()
  165. else:
  166. print "Pardon, my lord, I'm sure I don't know what you mean."
  167. print
  168. prompt_bed()
  169. except ValueError:
  170. print "Pardon, my lord, I'm sure I don't know what you mean."
  171. print
  172. prompt_bed()

Third room:

  1. # If you haven't opened the secret door, this description will trigger
  2. def lib_Desc1():
  3. print "You are standing in the library."
  4. print "An unusual, carved bookshelf packed full of musty tomes is set into the"
  5. print "northern wall. Fyrglyss lanterns, hung about at strategic locations, fill"
  6. print "the room with an unearthly glow."
  7. print "You see a single exit leading (W)est."
  8. print "Type 'help' for a list of commands."
  9. print
  10. prompt_lib()
  11.  
  12. # If you have opened the secret door, this description will trigger
  13. def lib_Desc2():
  14. print "You are standing in the library."
  15. print "Before you stands a darkened doorway to outside."
  16. print "Fyrglyss lanterns, hung about at strategic locations, fill the room with"
  17. print "an unearthly glow."
  18. print "You see exits leading (W)est and (In)."
  19. print "Type 'help' for a list of commands."
  20. print
  21. prompt_lib()
  22.  
  23. # The library prompt
  24. def prompt_lib():
  25. global inventory
  26. global gotLantern
  27. global bookOnShelf
  28. prompt_l = raw_input("Your orders, my liege? ").lower()
  29. try:
  30. if prompt_l == "w":
  31. bedroom()
  32. if prompt_l == "in":
  33. if bookOnShelf == 1:
  34. chamber()
  35. else:
  36. print "I'm sorry, my lord, I'm sure I don't know what you mean."
  37. print
  38. prompt_lib()
  39. elif prompt_l == "help":
  40. help1()
  41. prompt_lib()
  42. elif prompt_l == "i":
  43. print "Your inventory contains: "
  44. for item in inventory:
  45. print item
  46. print
  47. prompt_lib()
  48. elif prompt_l == "look":
  49. if bookOnShelf == 0:
  50. lib_Desc1()
  51. else:
  52. lib_Desc2()
  53. elif prompt_l == "ex shelf" or prompt_l == "ex bookshelf" or prompt_l == "ex shelves" or prompt_l == "ex bookshelves":
  54. print "These old bookshelves contain all manner of volumes. You see your diary"
  55. print "and an atlas among the rest of the arcane texts. You notice that there's"
  56. print "an empty space where a book seems to be missing."
  57. print
  58. prompt_lib()
  59. elif prompt_l == "ex diary":
  60. print "'Dear Diary: Got drunk. Dear Diary: Got drunker.'"
  61. print
  62. prompt_lib()
  63. elif prompt_l == "take diary":
  64. print "Ugh, no thanks. Too depressing."
  65. print
  66. prompt_lib()
  67. elif prompt_l == "ex atlas":
  68. print "Maps of all the places you'll never see. Not if you stay locked up in"
  69. print "here, at any rate."
  70. print
  71. prompt_lib()
  72. elif prompt_l == "take atlas":
  73. print "Maybe on the way out, when it'll be of some use."
  74. print
  75. prompt_lib()
  76. elif prompt_l == "drink potion" or prompt_l == "drink healing potion":
  77. if "a healing potion" in inventory:
  78. if leogasHp < 35:
  79. leogasHp = 35
  80. print "You've been healed! Your health is now ", leogasHp
  81. inventory.remove("a healing potion")
  82. else:
  83. print "You really ought to save that for when it counts."
  84. print
  85. prompt_lib()
  86. else:
  87. print "You don't have a healing potion."
  88. print
  89. prompt_lib()
  90. elif prompt_l == "ex lantern" or prompt_l == "ex lanterns":
  91. print "These shimmering lanterns sparkle with an ethereal glow."
  92. print
  93. prompt_lib()
  94. elif prompt_l == "take lantern" or prompt_l == "take lanterns":
  95. if "a fyrglyss lantern" in inventory:
  96. print "You've already got a lantern."
  97. else:
  98. print "You take one of the lanterns down from its peg and hook it over your arm."
  99. gotLantern = 1
  100. inventory += ["a fyrglyss lantern"]
  101. print "Your inventory now contains:"
  102. for item in inventory:
  103. print item
  104. print
  105. prompt_lib()
  106. elif prompt_l == "ex space" or prompt_l == "ex empty space":
  107. print "It's empty. There's nothing there. Totally blank. Full of zero. Packed with"
  108. print "nada."
  109. print
  110. prompt_lib()
  111. elif prompt_l == "take bookshelf" or prompt_l == "take shelf" or prompt_l == "take shelves" or prompt_l == "take bookshelves":
  112. print "This is no time to re-arrange the furniture."
  113. print
  114. prompt_lib()
  115. elif prompt_l == "put book on shelf" or prompt_l == "put book on bookshelf" or prompt_l == "put book on shelves" or prompt_l == "put strange book on shelf" or prompt_l == "put strange book on bookshelf" or prompt_l == "put strange book on shelves":
  116. if "a strange book" in inventory:
  117. print "You place the strange book in the empty space on the shelf."
  118. bookOnShelf = 1
  119. inventory.remove("a strange book")
  120. print "Suddenly you hear a great rumbling as the bookshelf slides away."
  121. print "Before you stands a darkened doorway and a flight of stairs leading down."
  122. print "You can feel fresh air wafting in through the opening."
  123. print "A way out!"
  124. else:
  125. print "You don't have a book in your possession."
  126. print
  127. prompt_lib()
  128. elif prompt_l == "q":
  129. quit()
  130. #You can get a spotted mushroom later in the game. If you eat it at anytime, you die.
  131. elif prompt_l == "eat mushroom" or prompt_l == "eat mushrooms":
  132. if "a spotted mushroom" in inventory:
  133. print "Colors and lights start to swirl before your eyes. You feel a portal"
  134. print "to another world opening."
  135. die()
  136. else:
  137. print "You don't have a spotted mushroom."
  138. print
  139. prompt_lib()
  140. else:
  141. print "Pardon, my lord, I'm sure I don't know what you mean."
  142. print
  143. prompt_lib()
  144. except ValueError:
  145. print "Pardon, my lord, I'm sure I don't know what you mean."
  146. print
  147. prompt_lib()

Can anyone help shorten this up? Alternate coding solutions welcome. I'm curious how else this could be done, since I only really know one way.
Last edited by k.wiseman; Jul 3rd, 2008 at 3:19 am. Reason: added comments
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC