Always reply-all so a copy goes to the list.

On 2/24/2011 2:20 PM, Christopher Brookes wrote:
Oh yes, did'nt think about it. I love this solution Ty :) !

BTW i add Character class, how can i add to it ONE power ?

Sorry I don't understand.

class Character():
""" Classe du personnage, ses movements, attaques, geston de l'expérience et du niveau""" def __init__(self,name,description,type,strenght,intelligence,agility,health,level):
self.name <http://self.name> = name
        self.description = description
        self.type = type
        self.strenght = strenght
        self.intelligence = intelligence
        self.agility = agility
        self.health = health
        self.level = level

    def hit(self,target):
        """ Calcule la puissance du coup et réduit la vie de la cible"""
        target.health -=self.strenght  // care about it is  - =
print (self.name <http://self.name>, "hit",target.name <http://target.name>, "for", self.strenght, "damage")




Sorry, object is very new for me...


2011/2/24 bob gailer <bgai...@gmail.com <mailto:bgai...@gmail.com>>

    On 2/24/2011 1:58 PM, Christopher Brookes wrote:

        Hi,

        I want to create some powers in my fight program.
        I want to know if dictionnaries is the best solution to do it.

        For now its look like this :


        //French name and description, don't care about it ;)

        power1= {}
        power1['Name'] = 'Flammes infernales'
        power1['Description'] = 'Embrase lenemi et le feu bruler'

        power2= {}
        power2['Name'] = 'Froid devorant'
        power2['Description'] = 'Gele lenemi sur place'

        powerAll= [power1,power2]

        but if i want to create like 20 powers, it will be long no ?
        is there any solution shorter (and better ?)

    1 - define a Power class and create instances

    class Power:
     def __init__(self, name, desc):
    self.name <http://self.name> = name
       self.desc = desc

    powerAll = [
     Power('Flammes infernales' , 'Embrase lenemi et le feu bruler'),
     Power('Froid devorant', 'Gele lenemi sur place')]

-- Bob Gailer
    919-636-4239
    Chapel Hill NC




--
Brookes Christopher.


--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to