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.

90 lines
3.2 KiB

from random import randint
class Presonnage:
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):
if self.cat == "guerrier":
return randint (1,20) + self.exp* 10
if self.cat == "magicien":
return randint (1,20) + self.exp* 10
if self.cat == "voleur":
return randint (1,20) + self.exp* 3
if self.cat == "elfe":
return randint (1,20) + self.exp* 8
def jet_defense (self):
if self.cat == "guerrier":
return randint(1,20) + self.exp* 8
if self.cat == "magicien":
return randint(1,20) + self.exp* 7
if self.cat == "voleur":
return randint(1,20) + self.exp* 9
if self.cat == "elfe":
return randint(1,20) + self.exp* 10
def change_pdv (self,nb_pdv):
self.pdv = nb_pdv + self.pdv
def change_exp (self,nb_exp):
self.exp = nb_exp + self.exp
def affiche_caracteristiques (self):
print ("ton nom es",self.nom,"tu es un(e)",self.cat,"tu as",self.pdv,"pv","et",self.exp,"exp")
def affiche_inventaire (self):
print (self.inventaire)
def game():
Player_1_nom = input ("comment vous appeler vous joueur 1?")
print ("bonjour cher",Player_1_nom)
Player_1_cat = input ("quelle catégorie voulez vous etre ? \n Pour un guerrier = 1. \n Pour un magicien = 2. \n Pour un Voleur = 3 \n et enfin un mage = 4.")
if Player_1_cat == "1":
Player_1_cat = "Apprenti Guerrier"
if Player_1_cat == "2":
Player_1_cat = "Puissant Magicien"
if Player_1_cat == "3":
Player_1_cat = "vicieux de Voleur"
if Player_1_cat == "4":
Player_1_cat = "magnifique Elfe"
print ("Bien que votre souhait sois exaucé vous etes un" ,Player_1_cat)
Player_2_nom = input ("A votre tour Joueur 2 comment vous appeler vous?")
print ("bonjour cher",Player_2_nom)
Player_2_cat = input ("quelle catégorie voulez vous etre ? \n Pour un guerrier = 1. \n Pour un magicien = 2. \n Pour un Voleur = 3 \n et enfin un mage = 4.")
if Player_2_cat == "1":
Player_2_cat = "Apprenti Guerrier"
if Player_2_cat == "2":
Player_2_cat = "Puissant Magicien"
if Player_2_cat == "3":
Player_2_cat = "Fripon le Voleur"
if Player_2_cat == "4":
Player_2_cat = "Un magnifique Elfe"
print ("Bien que votre souhait sois exaucé vous etes un" ,Player_2_cat)
Player_1 = Personnage (Player_1_nom, Player_1_cat)
Player_2 = Personnage (Player_2_nom, Player_2_cat)
def tour ():
while Player_1.pdv > 0 and player_2.pdv > 0 :
PL1_A = player_1.jet_attaque()
PL2_D = player_2.jet_defence()
if PL1_A > PL2_D:
Player_1.change_pdv(-randint(1,8))