Browse Source

avec tk

master
mathis 1 week ago
parent
commit
201ad19d02
  1. 16
      jeuderôleavectk.py

16
jeuderôleavectk.py

@ -88,7 +88,7 @@ def tour(attaquant, defenseur):
if attaquant == 'joueur':
action = action_var.get()
if action == "Attaquer":
if action == "Attaque":
dmg = joueur.jet_attaque()
shield = bot.jet_defense()
if dmg > shield:
@ -120,7 +120,7 @@ def tour(attaquant, defenseur):
else:
dmg = bot.jet_attaque()
action = action_var.get()
if action == "Défendre":
if action == "Défense":
shield = joueur.jet_defense()
if dmg > shield:
nb_pdv = (-1) * random.randint(1, 8)
@ -177,8 +177,7 @@ def start_game():
bot_hp_label.config(text=f"HP Bot: {bot.get_hp()}")
joueur_potion_label.config(text=f"Potions: {joueur.get_pot()}")
output_text.insert(tk.END, f"\nAcutel: Tour n° {nb_tour} (attaquez sur tour pair et defendez sur un tour impair)"
"\nSuivant: Tour n° {suiv_tour}")
output_text.insert(tk.END, f"\nAcutel: Tour n° {nb_tour} (attaquez sur tour pair et defendez sur un tour impair)")
# Random bot generator
def rand():
@ -196,7 +195,7 @@ root.geometry("600x500")
# Widgets
name_var = tk.StringVar()
class_var = tk.StringVar()
action_var = tk.StringVar(value="Attaquer")
action_var = tk.StringVar(value="Attaque")
name_label = tk.Label(root, text="Nom du joueur:")
name_label.pack()
@ -221,6 +220,9 @@ class_entry.pack()
start_button = tk.Button(root, text="Commencer le jeu", command=start_game)
start_button.pack()
stats = tk.Label(root, text="Les statistiques sont affichées ici:")
stats.pack()
joueur_hp_label = tk.Label(root, text="HP Joueur:")
joueur_hp_label.pack()
@ -233,10 +235,10 @@ joueur_potion_label.pack()
action_label = tk.Label(root, text="Action:")
action_label.pack()
action_menu = tk.OptionMenu(root, action_var, "Attaquer", "Potion", "Défendre")
action_menu = tk.OptionMenu(root, action_var, "Attaque", "Potion", "Défense")
action_menu.pack()
tour_button = tk.Button(root, text="Tour suivant", command=lambda: tour(joueur, bot))
tour_button = tk.Button(root, text="Lancer", command=lambda: tour(joueur, bot))
tour_button.pack()
output_text = tk.Text(root, height=10)

Loading…
Cancel
Save