943,648 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 395942
  • Python RSS
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Mar 3rd, 2009
0

Re: Python Game: Norbert Quest

Hmmm... I never thought of using a list.
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009
Mar 4th, 2009
0

Re: Python Game: Norbert Quest

For now, the Official Game is still some ways away, so this 10 level cap will be good. For the official game, there'll be an unlimited amount of levels and Higher damaging, more expensive weapons so the battles don't take hours (And trust me, they take hours if you're Level 100, I tried it). The TNL (to next level) of each level will be tnl+level*50, so for the first level, you'd have a 50 tnl, second level 150, third level 300 (It goes up from 0 by the previous TNL added to 50 times the level, so you can imagine it'll get really hard as you level up). And after it all works well, I'll work on a new function called 'Locations' (certain locations [such as a mansion or a circus or something with new enemies] will open up as you level up). It'll keep people playing (since it'll now save and they won't have to restart from level 1 every time) the game like it's a hobby instead of a 'minigame' if you will. Man it sure took long to type this. I wonder if you read it all. If you did, I'll give you a reputation, just ask me for one .
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009
Mar 4th, 2009
0

Re: Python Game: Norbert Quest

Ugh and I don't even know how I'm gonna incorporate the pictures in all this. I might as well leave the images until I'm a better Python User. G'night folks, sleep tight, don't let the pythons bite.
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009
Mar 4th, 2009
1

Re: Python Game: Norbert Quest

Just as a side note, you could make the game a lot easier (potentially faster too) if you would let the user select things by number.

For example when selecting "battle" "shop" or "exit" if the menu was:
Python Syntax (Toggle Plain Text)
  1. Available options:
  2. 1 - Battle
  3. 2 - Shop
  4. 3 - Exit
  5. What would you like to do?
The user could enter '1', '2' or '3' instead of having to type out the whole word.

The same could be applied to the battle sequence.

But even better, might be some way to more automate the battle...something like 'auto-attack' that would keep attacking until the monster was dead or you died. (Maybe you could work out a way for the player to make some input into the battle while it was in-progress?)

In my sample play, I don't believe I have ever been killed by a monster. Especially not after I upgraded my weapons.

Oh...another usability item...when you open the shop, it would be nice to tell them which weapon they're using and how much money they have so they would know what they could afford and which weapons would be an upgrade to the weapon they have.
Reputation Points: 344
Solved Threads: 116
Practically a Master Poster
Murtan is offline Offline
670 posts
since May 2008
Mar 4th, 2009
0

Re: Python Game: Norbert Quest

The basic weapons are gonna need to be pimped out because the enemy's HP is gonna sky rocket was past your at the later levels. And there'll be new weapons with the new locations, and there'll be monsters with higher level then you (for example, a monster with your level + 5 or 10 so they're harder to kill and you'd need weapon upgrades.

Oh yeah and the numbers thing. I've thought about it before but I forgot to put them in. The game also needs attack spells or healing spells during a battle, and it needs armor, which I've already got an idea for(Armor = 25, defence = random.randrange(10)+Armor or another number, EnemyAttack - defence = EnemyAttack).
Last edited by Norbert X; Mar 4th, 2009 at 4:34 pm.
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009
Mar 4th, 2009
0

Re: Python Game: Norbert Quest

I simply find this thread amazing, almost 200,000 views. It is now the top viewed python thread, beating second by almost 50 000 views. Im dumfounded how this works.. some google search i think must be leading here. Or norbert has 200 000 friends
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Mar 4th, 2009
0

Re: Python Game: Norbert Quest

I simply find this thread amazing, almost 200,000 views. It is now the top viewed python thread, beating second by almost 50 000 views. Im dumfounded how this works.. some google search i think must be leading here. Or norbert has 200 000 friends
Yep it's the last one.

I've check a bunch of google searches and if you search Python Game, Python Quest, Norbert Quest, or anything else similar to this (Including Python Levels) all leads here to Daniweb.com/NorbertQ. It's usually the first thing listed, or close to the top.

EDIT: Ugh nevermind that last one, and the first one. It's been overshadowed by Monty Python and the Quest for the Holy Grail Game searches. Other's are good though.
Last edited by Norbert X; Mar 4th, 2009 at 9:06 pm. Reason: Mistake in Searching
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009
Mar 4th, 2009
0

Re: Python Game: Norbert Quest

I need help. I couldn't really figure out that self thing you told me so I put self.variable in all the variables and it won't work. Here's the latest NorbertQuest (by the way I need a better name still):
Python Syntax (Toggle Plain Text)
  1. class NorbertQuest(object):
  2. import self
  3. import random
  4. self.w = 0
  5. self.level = 1
  6. self.m = random.randrange(50)+1+level*5
  7. self.cost = 0
  8. self.xp = 0
  9. self.health = 150
  10. self.ehealth = 100
  11. self.money = 0
  12. def Shop():
  13. self.weapon1 = "Steel Knuckles"
  14. self.weapon2 = "Knife"
  15. self.weapon3 = "Sword"
  16. self.weapon4 = "Gun"
  17. self.weapon5 = "Rocket Launcher"
  18. print \
  19. """
  20. What'll it be?
  21. 1 - Steel Knuckles 20$
  22. 2 - Knife 30$
  23. 3 - Sword 100$
  24. 4 - Gun 300$
  25. 5 - Rocket Launcher 1000$
  26. Type exit to quit.
  27. """
  28. self.z = input("Which weapon do you want?")
  29. if self.z == 1:
  30. self.cost = 20
  31. if self.money >= self.cost:
  32. print"You have bought",self.weapon1
  33. self.money = self.money - self.cost
  34. self.w = 1
  35. self.mode = "restart"
  36. elif self.money < self.cost:
  37. print"You don't have enough gold to buy this."
  38. raw_input("Press [enter] to exit.")
  39. self.mode = "restart"
  40. elif self.z == 2:
  41. self.cost = 30
  42. if self.money >= self.cost:
  43. print"You have bought",self.weapon2
  44. self.money = self.money - self.cost
  45. self.w = 2
  46. self.mode = "restart"
  47. elif self.money < self.cost:
  48. print"You don't have enough gold to buy this."
  49. raw_input("Press [enter] to exit.")
  50. self.mode = "restart"
  51. elif self.z == 3:
  52. self.cost = 100
  53. if money >= self.cost:
  54. print"You have bought",self.weapon3
  55. self.money = self.money - self.cost
  56. self.w = 3
  57. self.mode = "restart"
  58. elif self.money < self.cost:
  59. print"You don't have enough gold to buy this."
  60. raw_input("Press [enter] to exit.")
  61. self.mode = "restart"
  62. elif self.z == 4:
  63. self.cost = 300
  64. if money >= self.cost:
  65. print"You have bought",self.weapon4
  66. self.money = self.money - self.cost
  67. self.w = 4
  68. self.mode = "restart"
  69. elif self.money < self.cost:
  70. print"You don't have enough gold to buy this."
  71. raw_input("Press [enter] to exit.")
  72. self.mode = "restart"
  73. elif self.z == 5:
  74. self.cost = 1000
  75. if self.money >= self.cost:
  76. print"You have bought",self.weapon5
  77. self.money = self.money - self.cost
  78. self.w = 5
  79. self.mode = "restart"
  80. elif self.money < self.cost:
  81. print"You don't have enough gold to buy this."
  82. raw_input("Press [enter] to exit.")
  83. self.mode = "restart"
  84. elif self.z == "exit":
  85. self.mode = "restart"
  86.  
  87. def eAttack():
  88. self.attacke = random.randrange(10)+self.level*10
  89. return self.attacke
  90.  
  91. def HP():
  92. self.e = self.eAttack()
  93. self.health = self.health - self.e
  94. print"Your HP is",self.health
  95.  
  96. def nAttack():
  97. self.attack = random.randrange(10)+level*5
  98. if self.w == 1:
  99. self.attack = random.randrange(10)+20+level*5
  100. elif self.w == 2:
  101. self.attack = random.randrange(10)+35+level*5
  102. elif self.w == 3:
  103. self.attack = random.randrange(10)+55+level*5
  104. elif self.w == 4:
  105. self.attack = random.randrange(10)+80+level*5
  106. elif self.w == 5:
  107. self.attack = random.randrange(10)+110+level*5
  108. return self.attack
  109.  
  110. tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]
  111.  
  112. def LVL():
  113. if 1 <= level <= len(tnls):
  114. tnl = tnls[level-1]
  115. if tnl <= xp:
  116. level += 1
  117. if level > len(tnls):
  118. level = 100
  119. xp = 0
  120. print("Your new level is %d! Congratulations!" % level)
  121. if level == 100:
  122. print("Congratulations, you beat the Demo!")
  123.  
  124. def EnemyHP():
  125. self.n = self.nAttack()
  126. self.ehealth = self.ehealth - self.n
  127. print "Monster's HP is",ehealth
  128.  
  129. self.monster = "Giant Python!"
  130.  
  131. while True:
  132. print \
  133. """
  134. Welcome to NorbertQuest!
  135. Type:
  136. - [battle] to hunt monsters
  137. - [shop] to buy weapons
  138. - [exit] to quit the game.
  139. """
  140. self.mode = raw_input("What do you want to do?: ")
  141. if self.mode == "shop":
  142. Shop()
  143.  
  144. if self.mode == "battle":
  145. print"You have encountered a",monster,"What will you do?"
  146. self.health = 150+self.level*100
  147. self.ehealth = 100+self.level*125
  148. self.m = random.randrange(50)+1+self.level*5
  149. self.xpGain = random.randrange(25)+self.level+25
  150. self.xp = self.xpGain + self.xp
  151. LVL()
  152. while self.mode == "battle":
  153. self.fight = random.randrange(10)+1
  154. if self.fight == 1:
  155. self.monster = "Dragon!"
  156. elif self.fight == 2:
  157. self.monster = "Wild Cayote!"
  158. elif self.fight == 3:
  159. self.monster == "Jaguar!"
  160. elif self.fight == 4:
  161. self.monster = "Orc Lord!"
  162. elif self.fight == 5:
  163. self.monster = "Goblin!"
  164. elif self.fight == 6:
  165. self.monster = "Crazy Robot!"
  166. elif self.fight == 7:
  167. self.monster = "Werewolf!"
  168. elif self.fight == 8:
  169. self.monster = "Vampire!"
  170. elif self.fight == 9:
  171. self.monster = "Giant Spider!"
  172. elif self.fight == 10:
  173. self.monster = "Pirate King!"
  174. self.turn = raw_input("Do you want to Attack or Defend?")
  175.  
  176. if"attack"in self.turn:
  177. print"You're attacking!"
  178. EnemyHP()
  179. HP()
  180. elif"defend"in self.turn:
  181. print"You're defending!"
  182. print"Monster's HP is",self.ehealth
  183. print"Your HP is",self.health
  184. else:
  185. print"Type attack or Defend!"
  186.  
  187. if self.health <= 0:
  188. print"You are dead!"
  189. self.mode = "restart"
  190. resetHP()
  191. elif self.ehealth <= 0:
  192. print "You win the battle! You earn",m,"$!"
  193. self. money = self.money + self.m
  194. self.mode = "restart"
  195. resetHP()
  196. self.m = random.randrange(50)+1+self.level*5
  197. self.xpGain = random.randrange(25)+self.level+25
  198. self.xp = self.xpGain + self.xp
  199. LVL()
  200. print"You gain",self.xpGain,"Experience Points!"
  201.  
  202.  
  203.  
  204. if self.mode == "exit":
  205. self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ")
  206. if"yes"in self.exit:
  207. break
  208. elif"no"in self.exit:
  209. self.mode = "restart"
  210.  
  211.  
  212. raw_input("Press [enter] to exit.")
  213. n = NorbertQuest()
  214. n.HP()

I keep getting this error:
Python Syntax (Toggle Plain Text)
  1. Traceback (most recent call last):
  2. File "C:\Documents and Settings\taf\My Documents\Norbert Quest RPG v1", line 2, in <module>
  3. class NorbertQuest(object):
  4. File "C:\Documents and Settings\taf\My Documents\Norbert Quest RPG v1", line 4, in NorbertQuest
  5. self.w = 0
  6. NameError: name 'self' is not defined
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009
Mar 5th, 2009
0

Re: Python Game: Norbert Quest

Ah what you have to do is have an __init__ method, this is a method that runs when the class is instantiated (when you make a variable of it)
python Syntax (Toggle Plain Text)
  1. import random
  2. class NorbertQuest(object):
  3.  
  4. def __init__(self):
  5. self.w = 0
  6. self.level = 1
  7. self.m = random.randrange(50)+1+level*5
  8. self.cost = 0
  9. self.xp = 0
  10. self.health = 150
  11. self.ehealth = 100
  12. self.money = 0
  13. def Shop():
  14. self.weapon1 = "Steel Knuckles"
  15. self.weapon2 = "Knife"
  16. self.weapon3 = "Sword"
  17. self.weapon4 = "Gun"
  18. self.weapon5 = "Rocket Launcher"
  19. print \
  20. """
  21. What'll it be?
  22. 1 - Steel Knuckles 20$
  23. 2 - Knife 30$
  24. 3 - Sword 100$
  25. 4 - Gun 300$
  26. 5 - Rocket Launcher 1000$
  27. Type exit to quit.
  28. """
  29. self.z = input("Which weapon do you want?")
  30. if self.z == 1:
  31. self.cost = 20
  32. if self.money >= self.cost:
  33. print"You have bought",self.weapon1
  34. self.money = self.money - self.cost
  35. self.w = 1
  36. self.mode = "restart"
  37. elif self.money < self.cost:
  38. print"You don't have enough gold to buy this."
  39. raw_input("Press [enter] to exit.")
  40. self.mode = "restart"
  41. elif self.z == 2:
  42. self.cost = 30
  43. if self.money >= self.cost:
  44. print"You have bought",self.weapon2
  45. self.money = self.money - self.cost
  46. self.w = 2
  47. self.mode = "restart"
  48. elif self.money < self.cost:
  49. print"You don't have enough gold to buy this."
  50. raw_input("Press [enter] to exit.")
  51. self.mode = "restart"
  52. elif self.z == 3:
  53. self.cost = 100
  54. if money >= self.cost:
  55. print"You have bought",self.weapon3
  56. self.money = self.money - self.cost
  57. self.w = 3
  58. self.mode = "restart"
  59. elif self.money < self.cost:
  60. print"You don't have enough gold to buy this."
  61. raw_input("Press [enter] to exit.")
  62. self.mode = "restart"
  63. elif self.z == 4:
  64. self.cost = 300
  65. if money >= self.cost:
  66. print"You have bought",self.weapon4
  67. self.money = self.money - self.cost
  68. self.w = 4
  69. self.mode = "restart"
  70. elif self.money < self.cost:
  71. print"You don't have enough gold to buy this."
  72. raw_input("Press [enter] to exit.")
  73. self.mode = "restart"
  74. elif self.z == 5:
  75. self.cost = 1000
  76. if self.money >= self.cost:
  77. print"You have bought",self.weapon5
  78. self.money = self.money - self.cost
  79. self.w = 5
  80. self.mode = "restart"
  81. elif self.money < self.cost:
  82. print"You don't have enough gold to buy this."
  83. raw_input("Press [enter] to exit.")
  84. self.mode = "restart"
  85. elif self.z == "exit":
  86. self.mode = "restart"
  87.  
  88. def eAttack():
  89. self.attacke = random.randrange(10)+self.level*10
  90. return self.attacke
  91.  
  92. def HP():
  93. self.e = self.eAttack()
  94. self.health = self.health - self.e
  95. print"Your HP is",self.health
  96.  
  97. def nAttack():
  98. self.attack = random.randrange(10)+level*5
  99. if self.w == 1:
  100. self.attack = random.randrange(10)+20+level*5
  101. elif self.w == 2:
  102. self.attack = random.randrange(10)+35+level*5
  103. elif self.w == 3:
  104. self.attack = random.randrange(10)+55+level*5
  105. elif self.w == 4:
  106. self.attack = random.randrange(10)+80+level*5
  107. elif self.w == 5:
  108. self.attack = random.randrange(10)+110+level*5
  109. return self.attack
  110.  
  111. tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]
  112.  
  113. def LVL():
  114. if 1 <= level <= len(tnls):
  115. tnl = tnls[level-1]
  116. if tnl <= xp:
  117. level += 1
  118. if level > len(tnls):
  119. level = 100
  120. xp = 0
  121. print("Your new level is %d! Congratulations!" % level)
  122. if level == 100:
  123. print("Congratulations, you beat the Demo!")
  124.  
  125. def EnemyHP():
  126. self.n = self.nAttack()
  127. self.ehealth = self.ehealth - self.n
  128. print "Monster's HP is",ehealth
  129.  
  130. self.monster = "Giant Python!"
  131.  
  132. while True:
  133. print \
  134. """
  135. Welcome to NorbertQuest!
  136. Type:
  137. - [battle] to hunt monsters
  138. - [shop] to buy weapons
  139. - [exit] to quit the game.
  140. """
  141. self.mode = raw_input("What do you want to do?: ")
  142. if self.mode == "shop":
  143. Shop()
  144.  
  145. if self.mode == "battle":
  146. print"You have encountered a",monster,"What will you do?"
  147. self.health = 150+self.level*100
  148. self.ehealth = 100+self.level*125
  149. self.m = random.randrange(50)+1+self.level*5
  150. self.xpGain = random.randrange(25)+self.level+25
  151. self.xp = self.xpGain + self.xp
  152. LVL()
  153. while self.mode == "battle":
  154. self.fight = random.randrange(10)+1
  155. if self.fight == 1:
  156. self.monster = "Dragon!"
  157. elif self.fight == 2:
  158. self.monster = "Wild Cayote!"
  159. elif self.fight == 3:
  160. self.monster == "Jaguar!"
  161. elif self.fight == 4:
  162. self.monster = "Orc Lord!"
  163. elif self.fight == 5:
  164. self.monster = "Goblin!"
  165. elif self.fight == 6:
  166. self.monster = "Crazy Robot!"
  167. elif self.fight == 7:
  168. self.monster = "Werewolf!"
  169. elif self.fight == 8:
  170. self.monster = "Vampire!"
  171. elif self.fight == 9:
  172. self.monster = "Giant Spider!"
  173. elif self.fight == 10:
  174. self.monster = "Pirate King!"
  175. self.turn = raw_input("Do you want to Attack or Defend?")
  176.  
  177. if"attack"in self.turn:
  178. print"You're attacking!"
  179. EnemyHP()
  180. HP()
  181. elif"defend"in self.turn:
  182. print"You're defending!"
  183. print"Monster's HP is",self.ehealth
  184. print"Your HP is",self.health
  185. else:
  186. print"Type attack or Defend!"
  187.  
  188. if self.health <= 0:
  189. print"You are dead!"
  190. self.mode = "restart"
  191. resetHP()
  192. elif self.ehealth <= 0:
  193. print "You win the battle! You earn",m,"$!"
  194. self. money = self.money + self.m
  195. self.mode = "restart"
  196. resetHP()
  197. self.m = random.randrange(50)+1+self.level*5
  198. self.xpGain = random.randrange(25)+self.level+25
  199. self.xp = self.xpGain + self.xp
  200. LVL()
  201. print"You gain",self.xpGain,"Experience Points!"
  202.  
  203.  
  204.  
  205. if self.mode == "exit":
  206. self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ")
  207. if"yes"in self.exit:
  208. break
  209. elif"no"in self.exit:
  210. self.mode = "restart"
  211.  
  212.  
  213. raw_input("Press [enter] to exit.")
  214. n = NorbertQuest()
  215. n.HP()
Oh and in all your functions self needs to be the first argument.
python Syntax (Toggle Plain Text)
  1. def this(self):
  2. #do stuff
  3.  
  4. #rather than
  5. def this():
  6. #do stuff
When in a class the self argument is given automatically so when calling it you still only need to supply the ones you specify
python Syntax (Toggle Plain Text)
  1. class Test(object):
  2. def printforme(self, pr):
  3. print pr
  4.  
  5. t = Test()
  6. t.printforme("hello")#notice i dont need to worry about self?

Hope that helps you out
Reputation Points: 264
Solved Threads: 183
Veteran Poster
Paul Thompson is offline Offline
1,095 posts
since May 2008
Mar 5th, 2009
0

Re: Python Game: Norbert Quest

I'm still getting an error. Maybe I did something wrong?

Python Syntax (Toggle Plain Text)
  1. import random
  2. class NorbertQuest(object):
  3.  
  4.  
  5. def __init__(self):
  6. self.w = 0
  7. self.level = 1
  8. self.m = random.randrange(50)+1+level*5
  9. self.cost = 0
  10. self.xp = 0
  11. self.health = 150
  12. self.ehealth = 100
  13. self.money = 0
  14.  
  15. def Shop():
  16. self.weapon1 = "Steel Knuckles"
  17. self.weapon2 = "Knife"
  18. self.weapon3 = "Sword"
  19. self.weapon4 = "Gun"
  20. self.weapon5 = "Rocket Launcher"
  21. print \
  22. """
  23. What'll it be?
  24. 1 - Steel Knuckles 20$
  25. 2 - Knife 30$
  26. 3 - Sword 100$
  27. 4 - Gun 300$
  28. 5 - Rocket Launcher 1000$
  29. Type exit to quit.
  30. """
  31. self.z = input("Which weapon do you want?")
  32. if self.z == 1:
  33. self.cost = 20
  34. if self.money >= self.cost:
  35. print"You have bought",self.weapon1
  36. self.money = self.money - self.cost
  37. self.w = 1
  38. self.mode = "restart"
  39. elif self.money < self.cost:
  40. print"You don't have enough gold to buy this."
  41. raw_input("Press [enter] to exit.")
  42. self.mode = "restart"
  43. elif self.z == 2:
  44. self.cost = 30
  45. if self.money >= self.cost:
  46. print"You have bought",self.weapon2
  47. self.money = self.money - self.cost
  48. self.w = 2
  49. self.mode = "restart"
  50. elif self.money < self.cost:
  51. print"You don't have enough gold to buy this."
  52. raw_input("Press [enter] to exit.")
  53. self.mode = "restart"
  54. elif self.z == 3:
  55. self.cost = 100
  56. if money >= self.cost:
  57. print"You have bought",self.weapon3
  58. self.money = self.money - self.cost
  59. self.w = 3
  60. self.mode = "restart"
  61. elif self.money < self.cost:
  62. print"You don't have enough gold to buy this."
  63. raw_input("Press [enter] to exit.")
  64. self.mode = "restart"
  65. elif self.z == 4:
  66. self.cost = 300
  67. if money >= self.cost:
  68. print"You have bought",self.weapon4
  69. self.money = self.money - self.cost
  70. self.w = 4
  71. self.mode = "restart"
  72. elif self.money < self.cost:
  73. print"You don't have enough gold to buy this."
  74. raw_input("Press [enter] to exit.")
  75. self.mode = "restart"
  76. elif self.z == 5:
  77. self.cost = 1000
  78. if self.money >= self.cost:
  79. print"You have bought",self.weapon5
  80. self.money = self.money - self.cost
  81. self.w = 5
  82. self.mode = "restart"
  83. elif self.money < self.cost:
  84. print"You don't have enough gold to buy this."
  85. raw_input("Press [enter] to exit.")
  86. self.mode = "restart"
  87. elif self.z == "exit":
  88. self.mode = "restart"
  89.  
  90. def eAttack():
  91. self.attacke = random.randrange(10)+self.level*10
  92. return self.attacke
  93.  
  94. def HP():
  95. self.e = self.eAttack()
  96. self.health = self.health - self.e
  97. print"Your HP is",self.health
  98.  
  99. def nAttack():
  100. self.attack = random.randrange(10)+level*5
  101. if self.w == 1:
  102. self.attack = random.randrange(10)+20+level*5
  103. elif self.w == 2:
  104. self.attack = random.randrange(10)+35+level*5
  105. elif self.w == 3:
  106. self.attack = random.randrange(10)+55+level*5
  107. elif self.w == 4:
  108. self.attack = random.randrange(10)+80+level*5
  109. elif self.w == 5:
  110. self.attack = random.randrange(10)+110+level*5
  111. return self.attack
  112.  
  113. self.tnls = [100, 250, 450, 650, 900, 1200, 1550, 1950, 2400, 2900]
  114.  
  115. def LVL():
  116. if 1 <= self.level <= len(self.tnls):
  117. self.tnl = self.tnls[level-1]
  118. if self.tnl <= self.xp:
  119. self.level += 1
  120. if self.level > len(self.tnls):
  121. self.level = 100
  122. self.xp = 0
  123. print("Your new level is %d! Congratulations!" % se.flevel)
  124. if se.flevel == 100:
  125. print("Congratulations, you beat the Demo!")
  126.  
  127. def EnemyHP():
  128. self.n = self.nAttack()
  129. self.ehealth = self.ehealth - self.n
  130. print "Monster's HP is",self.ehealth
  131.  
  132. self.monster = "Giant Python!"
  133.  
  134. while True:
  135. print \
  136. """
  137. Welcome to NorbertQuest!
  138. Type:
  139. - [battle] to hunt monsters
  140. - [shop] to buy weapons
  141. - [exit] to quit the game.
  142. """
  143. self.mode = raw_input("What do you want to do?: ")
  144. if self.mode == "shop":
  145. Shop()
  146.  
  147. if self.mode == "battle":
  148. print"You have encountered a",monster,"What will you do?"
  149. self.health = 150+self.level*100
  150. self.ehealth = 100+self.level*125
  151. self.m = random.randrange(50)+1+self.level*5
  152. self.xpGain = random.randrange(25)+self.level+25
  153. self.xp = self.xpGain + self.xp
  154. LVL()
  155. while self.mode == "battle":
  156. self.fight = random.randrange(10)+1
  157. if self.fight == 1:
  158. self.monster = "Dragon!"
  159. elif self.fight == 2:
  160. self.monster = "Wild Cayote!"
  161. elif self.fight == 3:
  162. self.monster == "Jaguar!"
  163. elif self.fight == 4:
  164. self.monster = "Orc Lord!"
  165. elif self.fight == 5:
  166. self.monster = "Goblin!"
  167. elif self.fight == 6:
  168. self.monster = "Crazy Robot!"
  169. elif self.fight == 7:
  170. self.monster = "Werewolf!"
  171. elif self.fight == 8:
  172. self.monster = "Vampire!"
  173. elif self.fight == 9:
  174. self.monster = "Giant Spider!"
  175. elif self.fight == 10:
  176. self.monster = "Pirate King!"
  177. self.turn = raw_input("Do you want to Attack or Defend?")
  178.  
  179. if"attack"in self.turn:
  180. print"You're attacking!"
  181. EnemyHP()
  182. HP()
  183. elif"defend"in self.turn:
  184. print"You're defending!"
  185. print"Monster's HP is",self.ehealth
  186. print"Your HP is",self.health
  187. else:
  188. print"Type attack or Defend!"
  189.  
  190. if self.health <= 0:
  191. print"You are dead!"
  192. self.mode = "restart"
  193. resetHP()
  194. elif self.ehealth <= 0:
  195. print "You win the battle! You earn",m,"$!"
  196. self. money = self.money + self.m
  197. self.mode = "restart"
  198. resetHP()
  199. self.m = random.randrange(50)+1+self.level*5
  200. self.xpGain = random.randrange(25)+self.level+25
  201. self.xp = self.xpGain + self.xp
  202. LVL()
  203. print"You gain",self.xpGain,"Experience Points!"
  204.  
  205.  
  206.  
  207. if self.mode == "exit":
  208. self.exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ")
  209. if"yes"in self.exit:
  210. break
  211. elif"no"in self.exit:
  212. self.mode = "restart"
  213.  
  214.  
  215. raw_input("Press [enter] to exit.")
  216. n = NorbertQuest()
  217. n.HP()
Reputation Points: 52
Solved Threads: 0
Junior Poster in Training
Norbert X is offline Offline
87 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Ejecting trays of CDs
Next Thread in Python Forum Timeline: Looping through and removing parts of a list





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC