Browse Source

maison (est_gagnant)

master
mathis 3 weeks ago
parent
commit
cfe48f2d47
  1. 58
      jeu de rôle.py

58
jeu de rôle.py

@ -6,13 +6,13 @@ class Personne:
self.__xp = 1 self.__xp = 1
self.__cat = cat self.__cat = cat
if self.__cat == 'guerrier': if self.__cat == 'guerrier':
self.__hp = 30 self.__hp = 20
elif self.__cat == 'mage': elif self.__cat == 'mage':
self.__hp =20 self.__hp =20
elif self.__cat == 'voleur': elif self.__cat == 'voleur':
self.__hp = 26 self.__hp = 30
elif self.__cat == 'elfe': elif self.__cat == 'elfe':
self.__hp = 24 self.__hp = 22
if cat == 'guerrier': if cat == 'guerrier':
self.__inv = ['epee', 'potion'] self.__inv = ['epee', 'potion']
elif cat == 'mage': elif cat == 'mage':
@ -66,14 +66,58 @@ class Personne:
def jet_defense(self): def jet_defense(self):
return random.randint(1, 20) + (self.get_xp()*self.get_coef_def()) return random.randint(1, 20) + (self.get_xp()*self.get_coef_def())
def change_pdv(): def change_pdv(self, other, nb_pdv):
if self == self:
self.__hp += nb_pdv
if other != '':
other.__hp += nb_pdv
else:
pass pass
def change_exp(): 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 pass
def affiche_caracteristiques(): 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 pass
def affiche_inventaire(): 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 pass
Loading…
Cancel
Save