Skip to content

Commit

Permalink
FEAT: Modification affichage (#49)
Browse files Browse the repository at this point in the history
* FEAT: Modification de l'affichage

* CHORE: update AUTHORS.md
  • Loading branch information
TheoPosenel authored Nov 6, 2024
1 parent 405a762 commit 8af74a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
- Jimmy, Levacher, [email protected]
- Sebastien, LAFRIZI, [email protected]
- Davinson, DOGLAS PRINCE, [email protected]
- Théo, POSENEL, [email protected]
15 changes: 9 additions & 6 deletions src/demineur.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def __init__(self, fichier_sauvegarde='demineur.json', difficulte='moyen'):
else: # moyen
self.taille = 10
self.nombre_mines = 20
self.grille = [['.' for _ in range(self.taille)] for _ in range(self.taille)]
self.grille_visible = [['.' for _ in range(self.taille)] for _ in range(self.taille)]

self.grille = [['■' for _ in range(self.taille)] for _ in range(self.taille)]
self.grille_visible = [['■' for _ in range(self.taille)] for _ in range(self.taille)]
self.statistiques = Statistiques()
self.fichier_sauvegarde = fichier_sauvegarde
self.marques = set()
Expand Down Expand Up @@ -65,7 +66,7 @@ def decouvrir_cases(self, x, y):
return
if self.grille_visible[y][x] == 'F':
self.grille_visible[y][x] = self.grille[y][x]
if self.grille_visible[y][x] != '.':
if self.grille_visible[y][x] != '':
return
self.grille_visible[y][x] = self.grille[y][x]
if self.grille[y][x] == '0':
Expand All @@ -76,8 +77,9 @@ def decouvrir_cases(self, x, y):

def afficher_grille(self):
"""A Function to show the game's board"""
for ligne in self.grille_visible:
print(' '.join(ligne))
print(" "+ " ".join([str(i) for i in range(self.taille)]))
for idx, ligne in enumerate(self.grille_visible):
print(f"{idx:2}| " + ' '.join(ligne) + " |")

def charger_jeu(self):
"""
Expand Down Expand Up @@ -111,6 +113,7 @@ def jouer(self):
game_in_progress = True
self.statistiques.start_timer()
while game_in_progress:
print("\n [ Bienvenue au Démineur ! ] \n")
self.afficher_grille()
try:
entree = input("'f x y' pour marquer/démarquer ou 'x y' pour découvrir : ").split()
Expand Down Expand Up @@ -139,7 +142,7 @@ def jouer(self):
self.statistiques.record_loss()
break
self.decouvrir_cases(x, y)
if sum(row.count('.') for row in self.grille_visible) == self.nombre_mines:
if sum(row.count('') for row in self.grille_visible) == self.nombre_mines:
print("Gagne !")
#End the game
game_in_progress = False
Expand Down

0 comments on commit 8af74a7

Please sign in to comment.