Re: [Tutor] RPG game.

2005-05-20 Thread . ,
It works fine but, at the end of the program total damage has to be shown. 
Only single damage is shown. How can i change it?

---
import random

print \
  """
  Warrior - damage: 10~60
  Archer - damage: 0~100
  HP of Player: 100
  HP of the monster: 300"""

wp = raw_input("\n\nSelect between warrior and archer: ")

mob = 300
hit = 0
hp = 100
dmg = 0
atk = 0
run = ""

while (mob > 0):
hit += 1
mob = mob - dmg
hp = hp - atk

if wp == "warrior":
dmg = random.randrange(50) + 10
atk = random.randrange(10)

elif wp == "archer":
dmg = random.randrange(100)
atk = random.randrange(5)

else:
print "\nError"

print "\n", hit, "hits"
print "HP of", wp,":", hp,"/100"
print "HP of the monster:", mob,"/300"

print "\nYou defeated the monster by", hit,"hits,", dmg,"damage" #HERE

raw_input("")
---




And I tired to add a while loop to make the program able to run again. But, 
it doesn't work..

---
import random

print \
  """
  Warrior - damage: 10~60
  Archer - damage: 0~100
  HP of Player: 100
  HP of the monster: 300"""

wp = raw_input("\n\nSelect between warrior and archer: ")

mob = 300
hit = 0
hp = 100
dmg = 0
atk = 0
run = ""

while True:
while (mob > 0):
hit += 1
mob = mob - dmg
hp = hp - atk

if wp == "warrior":
dmg = random.randrange(50) + 10
atk = random.randrange(10)

elif wp == "archer":
dmg = random.randrange(100)
atk = random.randrange(5)

else:
print "\nError"

print "\n", hit, "hits"
print "HP of", wp,":", hp,"/100"
print "HP of the monster:", mob,"/300"

print "\nYou defeated the monster by", hit,"hits,", dmg,"damage"

run = raw_input("\n\nrun or exit ") #This Part

if run == "exit":
break

elif run == "run":
continue
else:
raw_input("\nError")
break
---

_
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] RPG game.

2005-05-20 Thread . ,
I can't see the error message because the program ends fast.


>From: "Kooser, Ara S" <[EMAIL PROTECTED]>
>To: ". ," <[EMAIL PROTECTED]>,tutor@python.org
>Subject: RE: [Tutor] RPG game.
>Date: Fri, 20 May 2005 08:32:42 -0600
>
>Could you post the error message?
>
>Ara
>
>
>
>
>
>
>Fatti non foste per viver come bruti, ma per seguir virtute e canoscenza
>- Dante Alighieri
>
>You were not made to live like brutes, but to pursue virtue and
>knowledge
>
>
>-Original Message-
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>Behalf Of . ,
>Sent: Friday, May 20, 2005 5:56 AM
>To: tutor@python.org
>Subject: [Tutor] RPG game.
>
>
>I'm trying to make an RPG game which is only consisted of texts. But, it
>
>doesn't work!
>
>thanks.
>
>
>---
>import random
>
>print \
>   """Warrior - damage: 10~60
>   Archer - damage: 0~100
>   HP of Player: 100
>   HP of the monster: 300"""
>
>wp = raw_input("\n\nSelect between warrior and Archer ")
>
>mob = 300
>hit = 0
>hp = 100
>run = ""
>
>while True:
> while (mob > 0):
> hit += 1
> mob = mob - dmg
> hp = hp - atk
>
> if (hp < 0):
> print "\nYour", wp, "has died by the monster(", mob, "hp)"
> break
>
> elif wp == "warrior":
> dmg = random.randrange(50) + 10
> atk = random.randrange(10)
>
> elif wp == "archer":
> dmg = random.randrange(100)
> atk - random.randrage(5)
>
> print "\n", hit, "hits"
> print "HP of", wp,":", hp,"/100"
> print "HP of the monster:", mob,"/300"
>
> print "\nYou defeated the monster by", hit,"hits,", dmg,"damage"
>
> run = raw_input("\n\nrun or exit ")
>
> if run == "exit":
> break
>
> elif run == "run":
> continue
> else:
> raw_input("\nError")
> break
>
>---
>
>_
>Don't just search. Find. Check out the new MSN Search!
>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>

_
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] RPG game.

2005-05-20 Thread Alberto Troiano
Hey

You must set dmg to a value before using it

The error is that the variable dmg hasn't been asigned yet

>wp = raw_input("\n\nSelect between warrior and Archer ")
>
>mob = 300
>hit = 0
>hp = 100
>run = ""
>
>while True:
> while (mob > 0):
> hit += 1
> mob = mob - dmg#HERE

before doing this and before the while you should type dmg=0 or the value 
you like

Best Regards

Alberto
>From: "Kooser, Ara S" <[EMAIL PROTECTED]>
>To: ". ," <[EMAIL PROTECTED]>, tutor@python.org
>Subject: Re: [Tutor] RPG game.
>Date: Fri, 20 May 2005 08:32:42 -0600
>
>Could you post the error message?
>
>Ara
>
>
>
>
>
>
>Fatti non foste per viver come bruti, ma per seguir virtute e canoscenza
>- Dante Alighieri
>
>You were not made to live like brutes, but to pursue virtue and
>knowledge
>
>
>-Original Message-
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
>Behalf Of . ,
>Sent: Friday, May 20, 2005 5:56 AM
>To: tutor@python.org
>Subject: [Tutor] RPG game.
>
>
>I'm trying to make an RPG game which is only consisted of texts. But, it
>
>doesn't work!
>
>thanks.
>
>
>---
>import random
>
>print \
>   """Warrior - damage: 10~60
>   Archer - damage: 0~100
>   HP of Player: 100
>   HP of the monster: 300"""
>
>wp = raw_input("\n\nSelect between warrior and Archer ")
>
>mob = 300
>hit = 0
>hp = 100
>run = ""
>
>while True:
> while (mob > 0):
> hit += 1
> mob = mob - dmg
> hp = hp - atk
>
> if (hp < 0):
> print "\nYour", wp, "has died by the monster(", mob, "hp)"
> break
>
> elif wp == "warrior":
> dmg = random.randrange(50) + 10
> atk = random.randrange(10)
>
> elif wp == "archer":
> dmg = random.randrange(100)
> atk - random.randrage(5)
>
> print "\n", hit, "hits"
> print "HP of", wp,":", hp,"/100"
> print "HP of the monster:", mob,"/300"
>
> print "\nYou defeated the monster by", hit,"hits,", dmg,"damage"
>
> run = raw_input("\n\nrun or exit ")
>
> if run == "exit":
> break
>
> elif run == "run":
> continue
> else:
> raw_input("\nError")
> break
>
>---
>
>_
>Don't just search. Find. Check out the new MSN Search!
>http://search.msn.click-url.com/go/onm00200636ave/direct/01/
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>___
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor


Gaucho


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] RPG game.

2005-05-20 Thread Kooser, Ara S
Could you post the error message?

Ara






Fatti non foste per viver come bruti, ma per seguir virtute e canoscenza
- Dante Alighieri

You were not made to live like brutes, but to pursue virtue and
knowledge


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of . ,
Sent: Friday, May 20, 2005 5:56 AM
To: tutor@python.org
Subject: [Tutor] RPG game.


I'm trying to make an RPG game which is only consisted of texts. But, it

doesn't work!

thanks.


---
import random

print \
  """Warrior - damage: 10~60
  Archer - damage: 0~100
  HP of Player: 100
  HP of the monster: 300"""

wp = raw_input("\n\nSelect between warrior and Archer ")

mob = 300
hit = 0
hp = 100
run = ""

while True:
while (mob > 0):
hit += 1
mob = mob - dmg
hp = hp - atk

if (hp < 0):
print "\nYour", wp, "has died by the monster(", mob, "hp)"
break

elif wp == "warrior":
dmg = random.randrange(50) + 10
atk = random.randrange(10)

elif wp == "archer":
dmg = random.randrange(100)
atk - random.randrage(5)

print "\n", hit, "hits"
print "HP of", wp,":", hp,"/100"
print "HP of the monster:", mob,"/300"

print "\nYou defeated the monster by", hit,"hits,", dmg,"damage"

run = raw_input("\n\nrun or exit ")

if run == "exit":
break

elif run == "run":
continue
else:
raw_input("\nError")
break

---

_
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor