Advertisement
Guest User

code TP1

a guest
Nov 14th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.54 KB | None | 0 0
  1. def afficher_damier_ascii(dico):
  2.     res = f'Légende: 1={dico["joueurs"][0]["nom"]}, 2={dico["joueurs"][1]["nom"]}' + '\n' + '   ' + '-'*35 + '\n'
  3.     for y in range(18, 1, -1):
  4.         if y % 2 == 0:
  5.             res += str(int(y / 2)) + ' | '
  6.             for x in range(0, 8, 1):
  7.                 if dico["joueurs"][0]["pos"] == [x+1,y / 2]:
  8.                     res += '1   '
  9.                 elif dico["joueurs"][1]["pos"] == [x+1,y / 2]:
  10.                     res += '2   '
  11.                 else:
  12.                     res += '.   '
  13.             for x in range(8, 9, 1):
  14.                 if dico["joueurs"][0]["pos"] == [x+1,y]:
  15.                     res += '1 ' + '|'
  16.                 elif dico["joueurs"][1]["pos"] == [x+1,y]:
  17.                     res += '2 ' + '|'
  18.                 else:
  19.                     res += '. ' + '|'                
  20.         else:
  21.             res += '\n' + '  |'
  22.             for x in range(1, 10):
  23.                 if x != 9:
  24.                     murs_présent = False
  25.                     for mur_horizontal in dico["murs"]["horizontaux"]:
  26.                         if [x-1, (y + 1) // 2] == mur_horizontal or mur_horizontal == [x, (y + 1) // 2]:
  27.                             murs_présent = True
  28.                     if murs_présent == True:
  29.                         res += '-' * 4
  30.                     else:
  31.                         res += ' ' * 4
  32.                 else:
  33.                     res += '   |' + '\n'
  34.     res += '\n' + '--|-----------------------------------' + '\n' + '  | 1   2   3   4   5   6   7   8   9'
  35.     return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement