refactor: remove view import from model

This commit is contained in:
2025-05-22 10:28:17 +02:00
parent e817b064e1
commit c50210db3f
2 changed files with 15 additions and 13 deletions

View File

@@ -15,7 +15,6 @@ import org.Models.Pieces.PieceO;
import org.Models.Pieces.PieceS; import org.Models.Pieces.PieceS;
import org.Models.Pieces.PieceT; import org.Models.Pieces.PieceT;
import org.Models.Pieces.PieceZ; import org.Models.Pieces.PieceZ;
import org.Views.VueGameOver;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class Jeu extends Observable implements Runnable { public class Jeu extends Observable implements Runnable {
@@ -102,10 +101,7 @@ public class Jeu extends Observable implements Runnable {
public boolean estFinPartie() { public boolean estFinPartie() {
for (Point caseColoree : this.grille.motifPieceCouranteColoriee()) { for (Point caseColoree : this.grille.motifPieceCouranteColoriee()) {
if (this.grille.getCase(caseColoree.y, caseColoree.x)) { if (this.grille.getCase(caseColoree.y, caseColoree.x)) {
new VueGameOver(grille.getScore(), e -> System.exit(0), () -> { finPartie();
System.out.println("\"rejouer\"clique");
reinitialiserPartie();
});
return true; return true;
} }
} }

View File

@@ -137,9 +137,15 @@ public class VueGrille extends JPanel implements Observer, Runnable {
updateGrille(); updateGrille();
} }
if (o instanceof Jeu && !afficherFenetreFinPartie) { if (o instanceof Jeu) {
if (!this.jeu.jeuEnCours) { Jeu jeu = (Jeu) o;
if (!jeu.jeuEnCours && !afficherFenetreFinPartie) {
afficherFenetreFinPartie = true; afficherFenetreFinPartie = true;
new VueGameOver(
jeu.getGrille().getScore(),
e -> System.exit(0),
() -> jeu.reinitialiserPartie()
);
} }
} }
} }