-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNarutoTourney.py
304 lines (247 loc) · 7.22 KB
/
NarutoTourney.py
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 22 14:00:52 2018
@author: Cisco
"""
import os
# os.chdir("/Users/Cisco/Desktop/M1 EIF/S2/Intro Python/ProjetPython")
os.chdir(os.getcwd())
import TourneyFunctions as TF
import random as rd
import time
# Character initialization
class Genin():
def __init__(self):
self.name = None
self.life = None
self.attack = None
self.defense = None
self.agility = None
self.score = 0
self.x_coord = 0
self.y_coord = 0
self.symbol = None
participants = []
Naruto = Genin()
Naruto.name = "Naruto"
Naruto.defense = 60
Naruto.attack = 70
Naruto.agility = 70
Naruto.life = 100
Naruto.symbol = "N "
participants.append(Naruto)
Sasuke = Genin()
Sasuke.name = "Sasuke"
Sasuke.defense = 70
Sasuke.attack = 70
Sasuke.agility = 90
Sasuke.life = 70
Sasuke.symbol = "S "
participants.append(Sasuke)
Shikamaru = Genin()
Shikamaru.name = "Shikamaru"
Shikamaru.defense = 100
Shikamaru.attack = 40
Shikamaru.agility = 50
Shikamaru.life = 60
Shikamaru.symbol = "$ "
participants.append(Shikamaru)
Sakura = Genin()
Sakura.name = "Sakura"
Sakura.defense = 80
Sakura.attack = 60
Sakura.agility = 60
Sakura.life = 50
Sakura.symbol = "<3"
participants.append(Sakura)
Gaara = Genin()
Gaara.name = "Gaara"
Gaara.defense = 80
Gaara.attack = 50
Gaara.agility = 60
Gaara.life = 100
Gaara.symbol = "G "
participants.append(Gaara)
Choji = Genin()
Choji.name = "Choji"
Choji.defense = 40
Choji.attack = 90
Choji.agility = 40
Choji.life = 70
Choji.symbol = "O "
participants.append(Choji)
Tenten = Genin()
Tenten.name = "Tenten"
Tenten.defense = 70
Tenten.attack = 30
Tenten.agility = 70
Tenten.life = 40
Tenten.symbol = "T "
participants.append(Tenten)
Neji = Genin()
Neji.name = "Neji"
Neji.defense = 60
Neji.attack = 50
Neji.agility = 90
Neji.life = 70
Neji.symbol = ":|"
participants.append(Neji)
RockLee = Genin()
RockLee.name = "Rock Lee"
RockLee.defense = 40
RockLee.attack = 90
RockLee.agility = 90
RockLee.life = 70
RockLee.symbol = "R "
participants.append(RockLee)
Kankuro = Genin()
Kankuro.name = "Kankuro"
Kankuro.defense = 70
Kankuro.attack = 70
Kankuro.agility = 50
Kankuro.life = 80
Kankuro.symbol = "K "
participants.append(Kankuro)
Ino = Genin()
Ino.name = "Ino"
Ino.defense = 60
Ino.attack = 50
Ino.agility = 50
Ino.life = 50
Ino.symbol = "I "
participants.append(Ino)
Shino = Genin()
Shino.name = "Shino"
Shino.defense = 80
Shino.attack = 30
Shino.agility = 60
Shino.life = 60
Shino.symbol = ":{"
participants.append(Shino)
Hinata = Genin()
Hinata.name = "Hinata"
Hinata.defense = 70
Hinata.attack = 30
Hinata.agility = 50
Hinata.life = 40
Hinata.symbol = ":("
participants.append(Hinata)
Kiba = Genin()
Kiba.name = "Kiba"
Kiba.defense = 70
Kiba.attack = 70
Kiba.agility = 50
Kiba.life = 80
Kiba.symbol = ":D"
participants.append(Kiba)
Rin = Genin()
Rin.name = "Rin"
Rin.defense = 80
Rin.attack = 20
Rin.agility = 40
Rin.life = 50
Rin.symbol = "oO"
participants.append(Rin)
Kago = Genin()
Kago.name = "Kago"
Kago.defense = 80
Kago.attack = 60
Kago.agility = 40
Kago.life = 30
Kago.symbol = "=3"
participants.append(Kago)
Tourney = TF.InitializeTree(participants)
TF.InitTourney(participants)
TourneyRound = 1
Arbre = []
# boucle définissant chaque round
while len(Tourney) > 1:
# boucle pour le round (sur les participants)
if TourneyRound < 4:
print("Round %s ! \n" % TourneyRound)
else:
print("Combat final ! \n")
time.sleep(5)
combats = TF.SplitTourney(Tourney)
n = len(combats)
for i in range(n):
compteur_combats = 1
genin1 = combats[i][0]
genin2 = combats[i][1]
print("%s (%s) vs %s (%s) ! \n" %(genin1.name, genin1.symbol.strip(" "), genin2.name, genin2.symbol.strip(" ")))
# boucle combat (while genin1.life > 0 and genin2.life > 0)
attaquant = rd.randint(0,1)
combattants = [genin1, genin2]
degat = 0
esquive = False
ind_crit = False
outputCombat = [combattants, degat, esquive, attaquant, ind_crit]
life1 = genin1.life
life2 = genin2.life
# Initialisation de l'affiche
genin1.x_coord = 2
genin1.y_coord = 3
genin2.x_coord = 3
genin2.y_coord = 3
TF.Show(genin1, genin2)
# combat
while genin1.life > 0 and genin2.life > 0:
# dégat / esquive
attaquant = outputCombat[3]
#outputCombat = TF.combat(genin1, genin2, attaquant)
time.sleep(0.5)
outputCombat = TF.combat(genin1, genin2, attaquant)
if outputCombat[2] == True:
print("%s a esquivé ! \n" % outputCombat[0][int(not(attaquant))].name)
# Afficher
possibilties = [[outputCombat[0][int(attaquant)].x_coord + 1, outputCombat[0][int(attaquant)].y_coord],
[outputCombat[0][int(attaquant)].x_coord, outputCombat[0][int(attaquant)].y_coord - 1],
[outputCombat[0][int(attaquant)].x_coord, outputCombat[0][int(attaquant)].y_coord + 1]]
index = rd.randint(0,2)
while possibilties[index][0] < 0 or possibilties[index][0] > 6 or possibilties[index][1] < 0 or possibilties[index][1] > 6:
index = rd.randint(0,2)
outputCombat[0][int(not(attaquant))].x_coord = possibilties[index][0]
outputCombat[0][int(not(attaquant))].y_coord = possibilties[index][1]
TF.Show(outputCombat[0][int(attaquant)], outputCombat[0][int(not(attaquant))])
else:
if outputCombat[4] == False:
print("%s a infligé %d de dégat !" %(outputCombat[0][int(attaquant)].name, outputCombat[1]))
else:
print("%s a porté un coup critique ! Dégat : %d" %(outputCombat[0][int(attaquant)].name, outputCombat[1]))
if genin1.life <= 0 and genin2.life > 0:
# genin2 a gagné le combat
genin2.score += 1
print("Le gagnant est %s !" % genin2.name )
print("\n \n")
genin2.life = life2
elif genin2.life <= 0 and genin1.life > 0:
# genin1 a gangé le combat
genin1.score += 1
print("Le gagnant est %s !" %genin1.name)
print("\n \n")
genin1.life = life1
else:
# ils se sont entretués
print("Les deux genin sont morts !")
print("\n \n")
print("Fin du combat")
print("Continuer ?")
input()
# nettoyage après combat console
TF.ClearScreen()
Tourney = TF.ActualizeTree(Tourney)
print("Fin du Round %s !" %TourneyRound )
print("Les gagnants sont :")
gagnants = []
for genin in Tourney:
gagnants.append(genin.name)
print(gagnants)
Arbre.append(gagnants)
input("Tapper Enter pour contineur...")
n = len(Tourney)
TourneyRound += 1
print("Le champion est %s !" %Tourney[0].name)
print("Arbre final du tournoi : \n")
for Round in Arbre:
print(Round)