yanis
2 years ago
commit
3b73aa0366
1 changed files with 111 additions and 0 deletions
@ -0,0 +1,111 @@ |
|||||
|
import random |
||||
|
|
||||
|
class Personnage: |
||||
|
|
||||
|
def __init__ (self, nom, cat): |
||||
|
|
||||
|
self.nom = nom |
||||
|
self.pdv = 20 |
||||
|
self.xp = 1 |
||||
|
self.cat = cat |
||||
|
|
||||
|
if self.cat == "guerrier" : |
||||
|
self.inventaire = ["épée", "potion"] |
||||
|
elif self.cat == "magicien" : |
||||
|
self.inventaire = ["bâton", "potion"] |
||||
|
elif self.cat == "voleur" : |
||||
|
self.inventaire = ["dague", "potion"] |
||||
|
elif self.cat == "elfe" : |
||||
|
self.inventaire = ["arc", "potion"] |
||||
|
|
||||
|
def jet_attaque (self): |
||||
|
|
||||
|
if self.cat == "guerrier" or self.cat == "magicien": |
||||
|
coef = 10 |
||||
|
elif self.cat == "voleur": |
||||
|
coef = 3 |
||||
|
elif self.cat == "elfe": |
||||
|
coef = 8 |
||||
|
return random.randint(1, 20) + self.xp * coef |
||||
|
|
||||
|
def jet_defense (self): |
||||
|
|
||||
|
if self.cat == "guerrier": |
||||
|
coef = 8 |
||||
|
elif self.cat == "magicien": |
||||
|
coef = 7 |
||||
|
elif self.cat == "voleur": |
||||
|
coef = 9 |
||||
|
elif self.cat == "elfe": |
||||
|
coef = 10 |
||||
|
return random.randint(1, 20) + self.xp * coef |
||||
|
|
||||
|
def change_pdv (self, nb_pdv): |
||||
|
self.pdv = self.pdv + nb_pdv |
||||
|
|
||||
|
def change_xp (self, nb_xp): |
||||
|
self.xp = self.xp + nb_xp |
||||
|
|
||||
|
def affiche_caracteristiques (self): |
||||
|
print("Le Champion", self.nom, " : ", self.cat, ", points de vie: ", self.pdv, ", expérience: ", self.xp) |
||||
|
|
||||
|
def affiche_inventaire (self): |
||||
|
print("inventaire : ", self.inventaire) |
||||
|
|
||||
|
|
||||
|
|
||||
|
def Main_Combat (): |
||||
|
|
||||
|
i=1 |
||||
|
|
||||
|
while player1.pdv > 0 and player2.pdv > 0: |
||||
|
if i % 2 != 0 : |
||||
|
if player1.jet_attaque() > player2.jet_defense() : |
||||
|
player2.change_pdv(- random.randint(1, 8)) |
||||
|
print(player1.nom," touche son adversaire, ", player2.nom," est blessé " ) |
||||
|
else : |
||||
|
player1.change_pdv(- random.randint(1, 4)) |
||||
|
print(player1.nom, " ne touche pas son adversaire, ", player1.nom," est blessé") |
||||
|
|
||||
|
else : |
||||
|
if player2.jet_attaque() > player1.jet_defense() : |
||||
|
player1.change_pdv(- random.randint(1, 8)) |
||||
|
print(player2.nom," touche son adversaire, ", player1.nom," est blessé " ) |
||||
|
else : |
||||
|
player2.change_pdv(- random.randint(1, 4)) |
||||
|
print(player2.nom, " ne touche pas son adversaire, ", player2.nom," est blessé " ) |
||||
|
i=i+1 |
||||
|
|
||||
|
print("bilan des 2 joueurs suite à l'attaque :") |
||||
|
player1.affiche_caracteristiques() |
||||
|
player2.affiche_caracteristiques() |
||||
|
|
||||
|
if player1.pdv <= 0: |
||||
|
winner = player2.nom |
||||
|
player2.change_xp(+1) |
||||
|
else : |
||||
|
winner = player1.nom |
||||
|
player1.change_xp(+1) |
||||
|
|
||||
|
|
||||
|
print("End of the meeting of the fighters !") |
||||
|
print("Le gagnant du combat est le Champion ", winner, " en ", i-1, " échange(s)") |
||||
|
player1.affiche_caracteristiques() |
||||
|
player2.affiche_caracteristiques() |
||||
|
|
||||
|
|
||||
|
|
||||
|
print ("Bonjour bienvenue sur ce jeu de role vous devez créer deux combattants en choissisant leurs noms et leurs catégorie ensuite le combat acharné démarrera !") |
||||
|
|
||||
|
|
||||
|
Test=False |
||||
|
while (Test==False): |
||||
|
player1 = Personnage(input("Joueur 1, veuillez entrez le nom : "), input("Joueur 1, veuillez choisir votre catégorie (guerrier, magicien, elfe, voleur) : ")) |
||||
|
player2 = Personnage(input("Joueur 2, veuillez entrez le nom : "), input("Joueur 2, veuillez choisir votre catégorie (guerrier, magicien, elfe, voleur): ")) |
||||
|
|
||||
|
if (player1.cat=="guerrier" or player1.cat=="magicien" or player1.cat=="voleur" or player1.cat=="elfe" ) and (player2.cat=="guerrier" or player2.cat=="magicien" or player2.cat=="voleur" or player2.cat=="elfe"): |
||||
|
Test = True |
||||
|
else: |
||||
|
print("ARGH nous rencontrons un problèmes cette catégorie ne semble existais, réessayer pour voir!") |
||||
|
|
||||
|
Main_Combat() |
Loading…
Reference in new issue