-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaffichage.py
More file actions
71 lines (54 loc) · 1.66 KB
/
affichage.py
File metadata and controls
71 lines (54 loc) · 1.66 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import json
import os
def recup_unicode (piece):
'''
permet de récupérer le carctère unicode de la piece en paramètre
in : piece -> str
out : unicode -> str
'''
path=os.getcwd()+'\pieces\\'+piece+'.json'
f=open(path,'r')
dic=json.load(f)
return dic["unicode"]
def affiche_tableau(tableauDeJeu):
'''
Permet d'afficher le tableau de jeu pour le joueur blanc (True)
'''
mainLine=' | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | '
separation='---|------------------------------------------------'
i=len(tableauDeJeu)-1
ligne=8
while (i>0):
line=' '+str(ligne)+' |'
for j in range (8):
if (tableauDeJeu[(ligne-1)*8+j] !=' '):
symbole=recup_unicode(tableauDeJeu[(ligne-1)*8+j]).strip()
else:
symbole=' '
line+=' '+str(symbole)+' |'
i-=1
print(line)
ligne-=1
print(separation)
print (mainLine)
def affiche_tableau_reverse(tableauDeJeu):
'''
Permet d'afficher le tableau de jeu pour le joueur noir (False)
'''
mainLine=' | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | '
separation='---|------------------------------------------------'
i=0
ligne=1
while (i<len(tableauDeJeu)):
line=' '+str(ligne)+' |'
for j in range (8):
if (tableauDeJeu[ligne*8-(j+1)] !=' '):
symbole=recup_unicode(tableauDeJeu[ligne*8-(j+1)]).strip()
else:
symbole=' '
line+=' '+str(symbole)+' |'
i+=1
print(line)
ligne+=1
print(separation)
print (mainLine)