diff --git a/Avancee.odt b/Avancee.odt new file mode 100644 index 0000000..a1e5ab0 Binary files /dev/null and b/Avancee.odt differ diff --git a/Case.java b/Case.java index 8b72ced..a410ec7 100644 --- a/Case.java +++ b/Case.java @@ -8,17 +8,17 @@ public class Case extends JPanel { private boolean visible; private boolean minee; private boolean reperee; - private boolean deminee; private ListenerCase listener; + private boolean finDePartie; // Définition du constructeur public Case(Grille grille, Dimension caseSize) { super(); // Initialisation des attributs this.visible=false; - this.reperee=false; - this.deminee=false; + this.reperee=false; this.grille=grille; + this.finDePartie=false; // On place un listener sur notre case pour qu'elle réagisse aux clicks du joueur this.listener = new ListenerCase(); @@ -31,28 +31,34 @@ public class Case extends JPanel { this.setBackground(new Color(70, 70, 70)); } - // Méthode qui permet de montrer la case, et de la considérer comme déminée + // Méthode qui permet de montrer la case, et fait perdre si elle est minée public void setVisible(){ - if (this.visible==false){ + if (!this.visible){ this.visible = true; - this.deminee = true; // On affiche une mine si la case est minée, sinon le nombre de mines autour d'elle - if (this.minee == true) { + if ((this.minee)&&(!this.finDePartie)) { + this.setBackground(new Color(200, 0, 0)); + this.grille.setAllVisible(); + this.finDePartie=true; + } + else if ((this.minee)&&(this.finDePartie)) { this.setBackground(new Color(236, 0, 140)); } else { this.setBackground(new Color(80, 80, 80)); + if (this.entourage > 0) { this.add(new Entourage(this.entourage, this.getSize())); } + this.grille.verifVictoire(); } + // Mise à jour de l'affichage de la case this.updateUI(); - if ((this.entourage == 0)&&(minee==false)) { + if ((this.entourage == 0)&&(!minee)) { this.grille.setEntourageVisible(this); } - this.grille.verifVictoire(); } } @@ -90,7 +96,6 @@ public class Case extends JPanel { public void setReperee(boolean reperee){ this.reperee=reperee; if ((reperee)&&(minee)){ - this.deminee=true; this.grille.verifVictoire(); } this.grille.MinesLeft(); @@ -101,8 +106,18 @@ public class Case extends JPanel { return this.reperee; } - // Methode pour dire si la case a été déminée - public boolean getDeminee(){ - return this.deminee; + // Methode pour montrer que la partie est gagnée + public void setVictoire(){ + this.finDePartie=true; + if (this.minee==true){ + removeAll(); + this.setBackground(new Color(236, 214, 0));; + + } + } + + // Methode pour savoir dans le Listener si la partie est finie ou non + public boolean getFinDePartie(){ + return this.finDePartie; } } diff --git a/Chiffre.java b/Chiffre.java deleted file mode 100644 index b70db3b..0000000 --- a/Chiffre.java +++ /dev/null @@ -1,21 +0,0 @@ -import javax.swing.JComponent; -import java.awt.*; - -public class Chiffre extends JComponent { - private int entourage; - private Dimension caseSize; - public Chiffre(int entourage, Dimension caseSize) { - super(); - this.entourage = entourage; - this.caseSize=caseSize; - } - @Override - protected void paintComponent(Graphics pinceau) { - Graphics chiffre = pinceau.create(); - Font font = new Font("Arial", Font.BOLD, caseSize.width*2/5); - chiffre.setFont(font); - Color jaune = new Color(236, 214, 0); - chiffre.setColor(jaune); - chiffre.drawString(Integer.toString(this.entourage),caseSize.width*2/5,caseSize.height*3/5); - } -} diff --git a/FrameVictoire.java b/FrameVictoire.java deleted file mode 100644 index 47f9a05..0000000 --- a/FrameVictoire.java +++ /dev/null @@ -1,5 +0,0 @@ -public class FrameVictoire { - public FrameVictoire(Grille grille){ - System.out.println("Victoire!"); - } -} diff --git a/Grille.java b/Grille.java index 4d25d8c..b276f21 100644 --- a/Grille.java +++ b/Grille.java @@ -28,7 +28,7 @@ public class Grille extends JPanel { this.mines=mines; this.banniere=banniere; // On génère le plateau contenant les cases - GenererPlateau(taille, caseSize); + GenererPlateau(caseSize); // Instalation des mines @@ -130,24 +130,31 @@ public class Grille extends JPanel { // On place les cases à leur état actuel dans la grille - AfficherPlateau(taille); + AfficherPlateau(); } // Méthode pour Génerer le plateau - protected void GenererPlateau(int taille, Dimension caseSize){ - this.plateau= new Case[taille]; - for (int i=0;i