You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.8 KiB

import random
class Personne:
def __init__(self, nom, cat):
self.__nom = nom
self.__xp = 1
self.__cat = cat
if self.__cat == 'guerrier':
self.__hp = 20
elif self.__cat == 'mage':
self.__hp =20
elif self.__cat == 'voleur':
self.__hp = 30
elif self.__cat == 'elfe':
self.__hp = 22
if cat == 'guerrier':
self.__inv = ['epee', 'potion']
elif cat == 'mage':
self.__inv = ['baton', 'potion']
elif cat == 'voleur':
self.__inv = ['dague', 'potion']
elif cat == 'elfe':
self.__inv = ['arc', 'potion']
if self.get_cat() == 'guerrier' or self.get_cat() == 'mage':
self.__coefAtq = 10
elif self.get_cat() == 'voleur':
self.__coefAtq = 3
elif self.get_cat() == 'elfe':
self.__coefAtq = 8
if self.get_cat() == 'guerrier':
self.__coefAtq = 8
if self.get_cat() == 'mage':
self.__coefDef = 7
elif self.get_cat() == 'voleur':
self.__coefDef = 9
elif self.get_cat() == 'elfe':
self.__coefDef = 10
def get_nom(self):
return self.__nom
def get_hp(self):
return self.__hp
def get_xp(self):
return self.__xp
def get_cat(self):
return self.__cat
def get_inv(self):
return self.__inv
def get_coef_atq(self):
return self.__coefAtq
def get_coef_def(self):
return self.__coefDef
def set_nom(self):
self.__nom = nom
def jet_attaque(self):
return random.randint(1, 20) + (self.get_xp()*self.get_coef_atq())
def jet_defense(self):
return random.randint(1, 20) + (self.get_xp()*self.get_coef_def())
def change_pdv(self, other, nb_pdv):
if self == self:
self.__hp += nb_pdv
if other != '':
other.__hp += nb_pdv
else:
pass
def change_exp(self, nb_exp):
self.__xp += nb_exp
def affiche_caracteristiques(self, other):
if self == self:
print('voici vos caractéristiques:',
'\n nom: ', self.get_nom(),
'\n catégorie: ', self.get_cat(),
'\n hp: ', self.get_hp(),
'\n xp: ', self.get_xp(),
)
if other != '':
print('\n voici ses caractéristiques:',
'\n nom: ', other.get_nom(),
'\n catégorie: ', other.get_cat(),
'\n hp: ', other.get_hp(),
'\n xp: ', other.get_xp(),
)
else:
pass
def affiche_inventaire(self, other):
if self == self:
print('\n votre inventaire: ', self.get_inv())
if other != '':
print('\n inventaire ennemie: ', other.get_inv())
else:
pass
def est_gagnant(self, other):
if self.__hp and if other.__hp > 0:
if self.jet_attaque() > other.jet_defense():
nb_pdv = (-1) * random.randint(1,8)
other.change_pdv('', nb_pdv)
self.affiche_caracteristiques(other)
print('vous avez infligé ', -nb_pdv, "pts de dégats à l'ennemie!")
elif self.jet_attaque() < other.jet_defense():
nb_pdv = (-1) * random.randint(1,4)
self.change_pdv('', nb_pdv)
self.affiche_caracteristiques(other)
print('vous avez reçu ', -nb_pdv, "pts de dégats de l'ennemie!")
else:
self.affiche_caracteristiques(other)
print('parade parfaite: aucun des joueur ne perd de points de vie')
else:
pass