[Tutor] RPG game.

Alberto Troiano albertito_g at hotmail.com
Fri May 20 16:45:08 CEST 2005


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" <askoose at sandia.gov>
>To: ". ," <administrata at hotmail.com>, tutor at 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: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
>Behalf Of . ,
>Sent: Friday, May 20, 2005 5:56 AM
>To: tutor at 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 at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor


Gaucho




More information about the Tutor mailing list