import random m = random.randrange(50)+1 #main health = 150 ehealth = 50 money = 0 def Shop(): global weapon weapon[0] = "Steel Knuckles" weapon[1] = "Knife" weapon[3] = "Sword" weapon[4] = "Gun" weapon[5] = "Rocket Launcher" print \ """ 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ """ z = input("Which weapon do you want?") if money >= cost: print"You have bought a",weapon[z] money = money - c mode = restart elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = restart def eAttack(): attacke = random.randrange(15)+1 return attacke def HP(): e = eAttack() global health health = health - e print"Your HP is",health def Gold(): global money def nAttack(): attack = random.randrange(10)+1 return attack def EnemyHP(): n = nAttack() global ehealth ehealth = ehealth - n print "Monster's HP is",ehealth while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ mode = raw_input("What do you want to do?: ") while"battle"in mode: turn = raw_input("Do you want to Attack or Defend?") if"attack"in turn: print"You're attacking!" EnemyHP() HP() elif"defend"in turn: print"You're defending!" print"Monster's HP is",ehealth print"Your HP is",health else: print"Type attack or Defend!" if health <= 0: print"You are dead!" mode = restart if ehealth <= 0: print "You win the battle! You earn",m,"$!" money = money + m while"exit"in mode: exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in exit: break elif"no"in exit: mode = restart raw_input("Press [enter] to exit.")
import random m = random.randrange(50)+1 #main health = 150 ehealth = 50 money = 0 def Shop(): weapon1 = "Steel Knuckles" weapon2 = "Knife" weapon3 = "Sword" weapon4 = "Gun" weapon5 = "Rocket Launcher" print \ """ 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ """ z = input("Which weapon do you want?") if money >= cost: if z = 1: c = 20 print"You have bought a",weapon[z] money = money - c if z = 2: c = 30 print"You have bought a",weapon[z] money = money - c if z = 3: c = 100 print"You have bought a",weapon[z] money = money - c if z = 4: c = 300 print"You have bought a",weapon[z] money = money - c if z = 5: c = 1000 print"You have bought a",weapon[z] money = money - c mode = restart elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = restart def eAttack(): attacke = random.randrange(15)+1 return attacke def HP(): e = eAttack() global health health = health - e print"Your HP is",health def Gold(): global money def nAttack(): attack = random.randrange(10)+1 return attack def EnemyHP(): n = nAttack() global ehealth ehealth = ehealth - n print "Monster's HP is",ehealth while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ mode = raw_input("What do you want to do?: ") while"battle"in mode: turn = raw_input("Do you want to Attack or Defend?") if"attack"in turn: print"You're attacking!" EnemyHP() HP() elif"defend"in turn: print"You're defending!" print"Monster's HP is",ehealth print"Your HP is",health else: print"Type attack or Defend!" if health <= 0: print"You are dead!" mode = restart if ehealth <= 0: print "You win the battle! You earn",m,"$!" money = money + m while"exit"in mode: exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in exit: break elif"no"in exit: mode = restart raw_input("Press [enter] to exit.")
import random w = 0 m = random.randrange(50)+1 cost = 0 #main health = 150 ehealth = 50 money = 0 def Shop(): global money weapon1 = "Steel Knuckles" weapon2 = "Knife" weapon3 = "Sword" weapon4 = "Gun" weapon5 = "Rocket Launcher" print \ """ 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ """ z = input("Which weapon do you want?") if z == 1: cost == 20 if money >= cost: print"You have bought",weapon1 money = money - cost w == 1 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" if z == 2: cost == 30 if money >= cost: print"You have bought",weapon2 money = money - cost w == 2 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" if z == 3: cost == 100 if money >= cost: print"You have bought",weapon3 money = money - cost w == 3 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" if z == 4: cost == 300 if money >= cost: print"You have bought",weapon4 money = money - cost w == 4 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" if z == 5: cost == 1000 if money >= cost: print"You have bought",weapon5 money = money - cost w == 5 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" def eAttack(): attacke = random.randrange(15)+1 return attacke def HP(): e = eAttack() global health health = health - e print"Your HP is",health if mode == "restart": health = 150 def Gold(): global money def nAttack(): attack = random.randrange(10)+1 return attack if w == 1: attack = random.randrange(20)+1 elif w == 2: attack = random.randrange(25)+1 elif w == 3: attack = random.randrange(30)+1 elif w == 4: attack = random.randrange(45)+1 elif w == 5: attack = random.randrange(60)+1 def EnemyHP(): n = nAttack() global ehealth ehealth = ehealth - n print "Monster's HP is",ehealth if mode == "restart": ehealth = 100 monster = 0 while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ mode = raw_input("What do you want to do?: ") while mode == "shop": Shop() while mode == "battle": fight = random.randrange(10)+1 if fight == 1: monster = "Dragon!" elif fight == 2: monster = "Wild Cayote!" elif fight == 3: monster == "Jaguar!" elif fight == 4: monster = "Orc Lord!" elif fight == 5: monster = "Goblin!" elif fight == 6: monster = "Crazy Robot!" elif fight == 7: monster = "Werewolf!" elif fight == 8: monster = "Vampire!" elif fight == 9: monster = "Giant Spider!" elif fight == 10: monster = "Pirate King" turn = raw_input("Do you want to Attack or Defend?") if"attack"in turn: print"You're attacking!" EnemyHP() HP() elif"defend"in turn: print"You're defending!" print"Monster's HP is",ehealth print"Your HP is",health else: print"Type attack or Defend!" if health <= 0: print"You are dead!" mode = "restart" elif ehealth <= 0: print "You win the battle! You earn",m,"$!" money = money + m mode = "restart" while mode == "exit": exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in exit: break elif"no"in exit: mode = "restart" raw_input("Press [enter] to exit.")
for idx in range(len(weaponlist)): print idx + 1, weaponlist[idx].description, weaponlist[idx].cost z = input("Which weapon do you want?") if money > weaponlist[z].cost: playerweapon = weaponlist[z] print "You have bought", playerweapon.description else: print "You can't afford the", weaponlist[z].description
== for comparison and = for assignment.
if z == 1: cost == 20 if money >= cost: print"You have bought",weapon1 money = money - cost w == 1 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart"
if z == 1: cost = 20 if money >= cost: print"You have bought",weapon1 money = money - cost w = 1 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart"
import random w = 0 m = random.randrange(50)+1 cost = 0 #main health = 150 ehealth = 50 money = 0 def Shop(): global money weapon1 = "Steel Knuckles" weapon2 = "Knife" weapon3 = "Sword" weapon4 = "Gun" weapon5 = "Rocket Launcher" print \ """ What'll it be? 1 - Steel Knuckles 20$ 2 - Knife 30$ 3 - Sword 100$ 4 - Gun 300$ 5 - Rocket Launcher 1000$ Type exit to quit. """ z = input("Which weapon do you want?") if z == 1: cost = 20 if money >= cost: print"You have bought",weapon1 money = money - cost w = 1 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" elif z == 2: cost = 30 if money >= cost: print"You have bought",weapon2 money = money - cost w = 2 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" elif z == 3: cost = 100 if money >= cost: print"You have bought",weapon3 money = money - cost w = 3 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" elif z == 4: cost = 300 if money >= cost: print"You have bought",weapon4 money = money - cost w = 4 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" elif z == 5: cost = 1000 if money >= cost: print"You have bought",weapon5 money = money - cost w = 5 mode = "restart" elif money < cost: print"You don't have enough gold to buy this." raw_input("Press [enter] to exit.") mode = "restart" elif z == "exit": mode = "restart" def eAttack(): attacke = random.randrange(15)+1 return attacke if mode = "restart": health = 100 def HP(): e = eAttack() global health health = health - e print"Your HP is",health if mode = "restart": health = 150 def Gold(): global money def nAttack(): attack = random.randrange(10)+1 return attack if w = 1: attack = random.randrange(20)+1 elif w = 2: attack = random.randrange(25)+1 elif w = 3: attack = random.randrange(30)+1 elif w = 4: attack = random.randrange(45)+1 elif w = 5: attack = random.randrange(60)+1 def EnemyHP(): n = nAttack() global ehealth ehealth = ehealth - n print "Monster's HP is",ehealth if mode = "restart": ehealth = 100 monster = 0 while True: print \ """ Welcome to NorbertQuest! Type: - [battle] to hunt monsters - [shop] to buy weapons - [exit] to quit the game. """ mode = raw_input("What do you want to do?: ") if mode == "shop": Shop() while mode == "battle": fight = random.randrange(10)+1 if fight == 1: monster = "Dragon!" elif fight == 2: monster = "Wild Cayote!" elif fight == 3: monster == "Jaguar!" elif fight == 4: monster = "Orc Lord!" elif fight == 5: monster = "Goblin!" elif fight == 6: monster = "Crazy Robot!" elif fight == 7: monster = "Werewolf!" elif fight == 8: monster = "Vampire!" elif fight == 9: monster = "Giant Spider!" elif fight == 10: monster = "Pirate King" turn = raw_input("Do you want to Attack or Defend?") if"attack"in turn: print"You're attacking!" EnemyHP() HP() elif"defend"in turn: print"You're defending!" print"Monster's HP is",ehealth print"Your HP is",health else: print"Type attack or Defend!" if health <= 0: print"You are dead!" mode = "restart" elif ehealth <= 0: print "You win the battle! You earn",m,"$!" money = money + m mode = "restart" if mode == "exit": exit = raw_input("Are you sure you want to quit? All progress will be lost. Yes or no: ") if"yes"in exit: break elif"no"in exit: mode = "restart" raw_input("Press [enter] to exit.")
| DaniWeb Message | |
| Cancel Changes | |