From 7340e41e2c82fa35b981908ddf9e3b7697fffb47 Mon Sep 17 00:00:00 2001 From: jordan <> Date: Sun, 22 Sep 2024 21:08:34 +0200 Subject: [PATCH] Sauvegarde d'un programme non fonctionnel --- miniprojet.py | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/miniprojet.py b/miniprojet.py index 34e0ba4..d539266 100644 --- a/miniprojet.py +++ b/miniprojet.py @@ -1,4 +1,5 @@ import tkinter as tk +import time from random import randint class Personnage: def __init__ (self, nom, cat): @@ -56,3 +57,80 @@ class Personnage: # Partie Jeu +def game(): + #Joueur N°1 (l'attaquant) + Pl1_name = input("Comment vous nommez-vous cher aventurier ? ") + print("Bonjour cher", Pl1_name) + Pl1_cat = input("Quelle catégorie voulez-vous être ? \n1: Guerrier \n2: Magicien \n3: Voleur \n4: Elfe\n") + + if Pl1_cat == "1": + Pl1_cat = "guerrier" + elif Pl1_cat == "2": + Pl1_cat = "magicien" + elif Pl1_cat == "3": + Pl1_cat = "voleur" + elif Pl1_cat == "4": + Pl1_cat = "elfe" + + print("Vous etes désormais un(e)", Pl1_cat) + + #Joueur N°2 (le défenseur) + Pl2_name = input("Et vous, aventurier N°2, comment vous nommez-vous ? ") + print("Bonjour cher", Pl1_name) + Pl2_cat = input("Quelle catégorie voulez-vous être ? \n1: Guerrier \n2: Magicien \n3: Voleur \n4: Elfe\n") + + if Pl2_cat == "1": + Pl2_cat = "guerrier" + elif Pl2_cat == "2": + Pl2_cat = "magicien" + elif Pl2_cat == "3": + Pl2_cat = "voleur" + elif Pl2_cat == "4": + Pl2_cat = "elfe" + + print("Vous etes maintenant un(e)", Pl2_cat) + + Player_1 = Personnage(Pl1_name, Pl1_cat) + Player_2 = Personnage(Pl2_name, Pl2_cat) + + print(Player_1.affiche_caracteristiques(), Player_1.affiche_inventaire()) + + time.sleep(1.5) + + print(Player_2.affiche_caracteristiques(), Player_2.affiche_inventaire()) + + time.sleep(2.5) + + + #La suite du programme ne marche pas "TypeError: 'int' object is not callable", j'ai beau chercher comment règler l'érreur je n'y arrive pas." + #De plus, il a pas l'air d'être très bon + while Player_1.pdv() > 0 and Player_2.pdv() > 0: + Attaquant = Player_1.jet_attaque() + Defenseur = Player_2.jet_defense() + if Attaquant > Defenseur: + nb_pdv = -(randint(1, 8)) + Player_2.change_pdv() + print(Player_2.nom(), "a été blessé lors de l'attaque, il a", Player_2.pdv(), "PV") + else: + nb_pdv = -(randint(1, 4)) + Player_1.change_pdv() + print(Player_1.nom(), "a été blessé suite à la défense, il a", Player_1.pdv(), "PV") + time.sleep(3) + + Attaquant = Player_1.jet_defense() + Defenseur = Player_2.jet_attaque() + + if Defenseur > Attaquant: + nb_pdv = -(randint(1, 8)) + Player_1.change_pdv() + print(Player_1.nom(), "a été blessé lors de l'attaque, il a", Player_1.pdv(), "PV") + else: + nb_pdv = -(randint(1, 4)) + Player_2.change_pdv() + print(Player_2.nom(), "a été blessé suite à la défense, il a", Player_2.pdv(), "PV") + time.sleep(3) + break + if Player_1.pdv() >= 1: + print(Player_1.nom(), "a gagné.") + else : + print(Player_2.nom(), "a gagné.") \ No newline at end of file