This repository was archived by the owner on Jun 9, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathSandBox11.py
More file actions
48 lines (45 loc) · 2.01 KB
/
Copy pathSandBox11.py
File metadata and controls
48 lines (45 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import random
create_perso = input("Voulez-vous créer un personnage ? (O/N) ")
if create_perso == "O":
persos = []
perso = {}
perso['nom'] = input("Nom du personnage : ")
perso['sexe'] = input("Sexe du personnage : ")
perso['race'] = input("Race du personnage : ")
perso['classe'] = input("Classe du personnage : ")
perso['niveau'] = int(input("Niveau du personnage : "))
perso['pv'] = int(input("Points de vie du personnage : "))
perso['dv'] = int(input("Dégâts de l'arme du personnage : "))
persos.append(perso)
print(persos)
perso_to_fight = {}
perso_to_fight['nom'] = input("Nom du personnage à combattre : ")
perso_to_fight['sexe'] = input("Sexe du personnage à combattre : ")
perso_to_fight['race'] = input("Race du personnage à combattre : ")
perso_to_fight['classe'] = input("Classe du personnage à combattre : ")
perso_to_fight['niveau'] = random.randint(1, 10)
perso_to_fight['pv'] = random.randint(1, 100)
perso_to_fight['dv'] = random.randint(1, 10)
persos.append(perso_to_fight)
print(persos)
else:
print("Ok, au revoir")
while perso['pv'] > 0 and perso_to_fight['pv'] > 0:
perso['pv'] -= perso_to_fight['dv']
perso_to_fight['pv'] -= perso['dv']
print(f"Le personnage {perso['nom']} a subit {perso_to_fight['dv']} de dégats et a maintenant {perso['pv']} PV")
print(
f"Le personnage {perso_to_fight['nom']} a subit {perso['dv']} de dégats et a maintenant {perso_to_fight['pv']} PV")
if perso['pv'] <= 0:
print(f"Le personnage {perso_to_fight['nom']} a gagné")
elif perso_to_fight['pv'] <= 0:
print(f"Le personnage {perso['nom']} a gagné")
else:
recommencer = input("Voulez-vous recommencer le combat ? (O/N) ")
if recommencer == "O":
perso['pv'] = int(input("Points de vie du personnage : "))
perso_to_fight['niveau'] = random.randint(1, 10)
perso_to_fight['pv'] = random.randint(1, 100)
perso_to_fight['dv'] = random.randint(1, 10)
else:
print("Au revoir")