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.
118 lines
3.8 KiB
118 lines
3.8 KiB
import random
|
|
class Personnage :
|
|
|
|
def __init__ (self, nom, cat) :
|
|
self.nom = nom
|
|
self.pdv = 20
|
|
self.exp = 1
|
|
self.cat =cat
|
|
if self.cat == "guerrier":
|
|
self.inventaire = ["épée", "potion"]
|
|
if self.cat == "magicien":
|
|
self.inventaire = ["bâton", "potion"]
|
|
if self.cat == "voleur":
|
|
self.inventaire = ["dague", "potion"]
|
|
if self.cat == "elfe":
|
|
self.inventaire = ["arc", "potion"]
|
|
|
|
def jet_attaque (self):
|
|
dé = random.randint(1, 20)
|
|
if self.cat == "voleur" :
|
|
mult = self.exp*3
|
|
if self.cat == "elfe" :
|
|
mult = self.exp*8
|
|
else :
|
|
mult = self.exp*10
|
|
return mult + dé
|
|
|
|
|
|
def jet_defense (self):
|
|
dé = random.randint(1, 20)
|
|
if self.cat == "voleur" :
|
|
mult = self.exp*9
|
|
if self.cat == "elfe" :
|
|
mult = self.exp*10
|
|
if self.cat == "guerrier" :
|
|
mult = self.exp*8
|
|
if self.cat == "magicien" :
|
|
mult = self.exp*7
|
|
return mult + dé
|
|
|
|
def change_pdv (self, nb_pdv) :
|
|
self.pdv = self.pdv + nb_pdv
|
|
|
|
def change_exp(self , nb_exp) :
|
|
self.exp = self.exp + nb_exp
|
|
|
|
def affiche_caracteristiques(self) :
|
|
print("ton nom est", self.nom, "ta catégorie est", self.cat, "ton nombre de point de vie est", self.pdv,"et tu as ", self.exp, "d experience")
|
|
|
|
def affiche_inventaire(self) :
|
|
print(self.inventaire)
|
|
|
|
|
|
nom_choisi1 = input("Choisis ton nom : ")
|
|
categorie_choisie1 = input("Choisis ta catégorie (guerrier, magicien, voleur, elfe) : ")
|
|
nom_choisi2 = input("Choisis ton nom : ")
|
|
categorie_choisie2 = input("Choisis ta catégorie (guerrier, magicien, voleur, elfe) : ")
|
|
def combat (joueur1, joueur2) :
|
|
while joueur1.pdv > 0 and joueur2.pdv > 0:
|
|
print()
|
|
print()
|
|
print(joueur1.nom,"est attaquant")
|
|
print(joueur2.nom,"est defenseur")
|
|
if joueur1.jet_attaque() > joueur2.jet_defense() :
|
|
dé = random.randint(1, 8)
|
|
joueur2.pdv = joueur2.pdv - dé
|
|
else :
|
|
dé = random.randint(1, 4)
|
|
joueur1.pdv = joueur1.pdv - dé
|
|
print()
|
|
joueur1.affiche_caracteristiques()
|
|
print()
|
|
joueur2.affiche_caracteristiques()
|
|
|
|
if joueur1.pdv <= 0 or joueur2.pdv <= 0:
|
|
if joueur1.pdv <= 0:
|
|
print()
|
|
print(joueur2.nom,"gagne le combat et gagne 1 point d'expérience.")
|
|
joueur2.exp = joueur2.exp + 1
|
|
else:
|
|
print()
|
|
print(joueur1.nom,"gagne le combat et gagne 1 point d'expérience.")
|
|
joueur1.exp = joueur1.exp + 1
|
|
return
|
|
|
|
print()
|
|
print()
|
|
print(joueur2.nom,"est attaquant")
|
|
print(joueur1.nom,"est defenseur")
|
|
if joueur2.jet_attaque() > joueur1.jet_defense() :
|
|
dé = random.randint(1, 8)
|
|
joueur1.pdv = joueur1.pdv - dé
|
|
else :
|
|
dé = random.randint(1, 4)
|
|
joueur2.pdv = joueur2.pdv - dé
|
|
print()
|
|
joueur1.affiche_caracteristiques()
|
|
print()
|
|
joueur2.affiche_caracteristiques()
|
|
|
|
if joueur1.pdv <= 0 or joueur2.pdv <= 0:
|
|
if joueur1.pdv <= 0:
|
|
print()
|
|
print(joueur2.nom,"gagne le combat et gagne 1 point d'expérience.")
|
|
joueur2.exp = joueur2.exp + 1
|
|
else:
|
|
print()
|
|
print(joueur1.nom,"gagne le combat et gagne 1 point d'expérience.")
|
|
joueur1.exp = joueur1.exp + 1
|
|
return
|
|
|
|
pers1 = Personnage(nom_choisi1,categorie_choisie1)
|
|
pers2 = Personnage (nom_choisi2,categorie_choisie2)
|
|
|
|
|
|
|
|
|
|
|
|
|