Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help: Program not doing what it's supposed to
#3
(12-09-2009, 03:08 PM)FarOut Wrote: You've got to stop posting code like this...

You create a new scanner object inside the if-block, why?

Make your variable names descriptive. Every time you use a cryptic variable name, a baby dies.

Learn what an array is.

The problem is that you never change the value of 'cero', why the variable even exists, I have no idea.

Remember, every undescriptive variable name leads to a dead baby....

When I posted this, people were telling me to shorten my variable names...
Code:
def a(classname,highdamageweaponname,lowdamageweaponname,ldmgname,hdmgname,yourhealth,enemyhealth,ldmgspellname,hdmgspellname):
import os
import random
os.system("clear")
monsters = ['cyclopse', 'duck', 'dragon', 'wizard', 'magician']
randommonster = random.choice(monsters)
print "Class: %s" % classname
print "1) %s (More damage, but less armor)" % highdamageweaponname
print "2) %s (Less damage, but more armor)" % lowdamageweaponname
a = int(raw_input("You are battling a %s what weapon do you want?: " % randommonster))
while enemyhealth >= -1 and yourhealth >= -1:
hdmg = [0,5,0,15,0,20,30]
ldmg = [0,5,6,7,8,9,10]
ldmgrandom = random.choice(ldmg)
hdmgrandom = random.choice(hdmg)
edmg = [ldmgrandom,hdmgrandom]
edmgrandom = random.choice(edmg)
mdmg = [1,2,3]
mdmgrandom = random.choice(mdmg)
os.system("clear")
if a == 1:
print "you have chosen a %s" % highdamageweaponname
print "Your Armor: ", yourhealth
print "Enemy Armor: ", enemyhealth
print "1) %s (High damage | High chance of missing)" % hdmgname
print "2) %s (Low damage | Low chance of missing)" % ldmgname
c = int(raw_input("Choose your attack: "))
if c == 1:
ddmg = hdmgrandom
yourhealth = yourhealth - edmgrandom
enemyhealth= enemyhealth- ddmg
print "You Did ", ddmg, "Damage"
raw_input("Press Enter To Continue")
elif c == 2:
ddmg = hdmgrandom
yourhealth = yourhealth - edmgrandom
enemyhealth= enemyhealth- ddmg
print "You Did ", ddmg, "Damage"
raw_input("Press Enter To Continue")
if a == 2:
print "you have chosen a %s" % lowdamageweaponname
print "Your Armor: ", yourhealth + 20
print "Enemy Armor: ", enemyhealth
print "1) %s (High damage | High chance of missing)" % hdmgspellname
print "2) %s (Low damage | Low chance of missing)" % ldmgspellname
c = int(raw_input("Choose your attack: "))

if c == 1:
ddmg = hdmgrandom
yourhealth = yourhealth - edmgrandom
enemyhealth= enemyhealth- (ddmg - mdmgrandom)
print "You Did ", ddmg, "Damage"
raw_input("Press Enter To Continue")
elif c == 2:
ddmg = ldmgrandom
yourhealth = yourhealth - edmgrandom
enemyhealth= enemyhealth- (ddmg - mdmgrandom)
print "You Did ", ddmg, "Damage"
raw_input("Press Enter To Continue")
if c > 2 or c < 1:
print "Invalid attack"
raw_input("Press Enter To Continue")
if yourhealth <= 0:
os.system("clear")
print "You Died..."

elif enemyhealth<= 0:
os.system("clear")
print "You Killed Him!"
def menu():
import os
import random
os.system("clear")
print "############################################"
print " City of Warscape "
print "###########################################"
print " "
print "Choose Your Class"
print "1) Warrior"
print "2) Ranger"
print "3) Mage"
x = int(raw_input("What Class What You Like To Be?: "))
if x == 1:
a('Warrior','Mace','Sword','Pound','Bash',100,100,'Slice','Dice')
if x == 2:
a('Ranger','Bow','Knives','Steady Shot','Power Shot',100,100,'Toss','Hurl')
if x == 3:
a('Mage','Staff','Wand','Poke','Slash',100,100,'Fireball','Froststrike')
menu()
the tabs got screwed up, but you can see the variable names
Reply


Messages In This Thread
RE: Help: Program not doing what it's supposed to - by nevets04 - 12-09-2009, 10:03 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)