From 0c032153ea910ad2a8e6029803aefa43e62646c8 Mon Sep 17 00:00:00 2001 From: Justine Yannis Date: Thu, 20 Oct 2022 14:25:27 +0200 Subject: [PATCH] =?UTF-8?q?Modification=20Makefile=20et=20fonction=20switc?= =?UTF-8?q?hPlayer=20qui=20=C3=A9tait=20pr=C3=A9vu=20pour=20un=20seul=20ty?= =?UTF-8?q?pe=20de=20constantes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projetAgile/Makefile | 28 ++++++++++--------- .../Controller/ModelEventListener.java | 1 - .../projetAgile/Model/GrilleModel.java | 2 +- .../projetAgile/Utils/Constants.java | 6 ++-- .../projetAgile/View/Puissance4Panel.java | 1 - 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/projetAgile/Makefile b/projetAgile/Makefile index bf90691..f4a6539 100644 --- a/projetAgile/Makefile +++ b/projetAgile/Makefile @@ -5,8 +5,11 @@ PACKAGE_PATH = fr/iutfbleau/projetAgile JAR_OPTION = cvfe projetAgile.jar $(PACKAGE).main.Main -C build fr -C res #BBUT PAR DEFAUT -run: puissance4 - java -jar Puissance4.jar +run: ArgileGames.jar + java -jar ArgileGames.jar + +ArgileGames.jar : build/$(PACKAGE_PATH)/Main.class + jar cvfe ArgileGames.jar $(PACKAGE_PATH).Main -C build fr -C res images #------- Dossiers ------ View = build/$(PACKAGE_PATH)/View/Pion.class \ @@ -26,7 +29,7 @@ Events = build/$(PACKAGE_PATH)/Event/GridChangedListener.class \ Model = build/$(PACKAGE_PATH)/Model/GrilleModel.class Controller = build/$(PACKAGE_PATH)/Controller/GrilleMouseListener.class \ - build/$(PACKAGE_PATH)/Controller/ModelEventListener.class \ + build/$(PACKAGE_PATH)/Controller/ModelEventListener.class #------- Events ------ build/$(PACKAGE_PATH)/Event/PlayerEvent.class : src/$(PACKAGE_PATH)/Event/PlayerEvent.java @@ -63,7 +66,7 @@ build/$(PACKAGE_PATH)/Controller/ObservateurMenuSouris.class : src/$(PACKAGE_PAT build/$(PACKAGE_PATH)/View/BoutonsMenu.class javac $(JAVAC_OPT) $< -build/$(PACKAGE_PATH)/Puissance4Controller.class : src/$(PACKAGE_PATH)/Controller/Puissance4Controller.java \ +build/$(PACKAGE_PATH)/Controller/Puissance4Controller.class : src/$(PACKAGE_PATH)/Controller/Puissance4Controller.java \ build/$(PACKAGE_PATH)/Model/GrilleModel.class \ build/$(PACKAGE_PATH)/View/Grille.class \ build/$(PACKAGE_PATH)/Utils/GameStatus.class \ @@ -101,26 +104,25 @@ build/$(PACKAGE_PATH)/View/Puissance4Panel.class : src/$(PACKAGE_PATH)/View/Pui build/$(PACKAGE_PATH)/View/Pion.class \ build/$(PACKAGE_PATH)/View/Grille.class \ build/$(PACKAGE_PATH)/Controller/ResetGame.class \ - build/$(PACKAGE_PATH)/View/Menu.class + build/$(PACKAGE_PATH)/Utils/Constants.class javac $(JAVAC_OPT) $< - jar cvfe Puissance4.jar $(PACKAGE_PATH).Main -C build fr -C res images build/$(PACKAGE_PATH)/View/BoutonsMenu.class : src/$(PACKAGE_PATH)/View/BoutonsMenu.java javac $(JAVAC_OPT) $< build/$(PACKAGE_PATH)/View/Menu.class : src/$(PACKAGE_PATH)/View/Menu.java \ - build/$(PACKAGE_PATH)/Controller/ObservateurMenuSouris.class \ - build/$(PACKAGE_PATH)/View/BoutonsMenu.class + build/$(PACKAGE_PATH)/Controller/ObservateurMenuSouris.class \ + build/$(PACKAGE_PATH)/View/BoutonsMenu.class javac $(JAVAC_OPT) $< -build/$(PACKAGE_PATH)/Main.class : src/$(PACKAGE_PATH)/Main.java +build/$(PACKAGE_PATH)/Main.class : src/$(PACKAGE_PATH)/Main.java \ + build/$(PACKAGE_PATH)/View/Menu.class \ + build/$(PACKAGE_PATH)/Controller/Puissance4Controller.class \ + build/$(PACKAGE_PATH)/View/Grille.class \ + build/$(PACKAGE_PATH)/Model/GrilleModel.class javac $(JAVAC_OPT) $< -puissance4 : build/$(PACKAGE_PATH)/Main.class \ - build/$(PACKAGE_PATH)/Puissance4Controller.class \ - $(Model) - doc : javadoc -d doc src/$(PACKAGE_PATH)/View/*.java src/$(PACKAGE_PATH)/Controller/*.java src/$(PACKAGE_PATH)/Utils/*.java src/$(PACKAGE_PATH)/Model/*.java src/$(PACKAGE_PATH)/Event/*.java diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ModelEventListener.java b/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ModelEventListener.java index b4c1d7e..c24ff85 100644 --- a/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ModelEventListener.java +++ b/projetAgile/src/fr/iutfbleau/projetAgile/Controller/ModelEventListener.java @@ -18,7 +18,6 @@ public class ModelEventListener implements GridChangedListener { @Override public void playerChanged(PlayerEvent e) { - //System.out.println("Tour du joueur : " + (e.getNewPlayer() == Constants.PLAYER_ONE ? "Rouge" : "Jaune")); this.panel.changeLabel(e.getNewPlayer()); } } diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/Model/GrilleModel.java b/projetAgile/src/fr/iutfbleau/projetAgile/Model/GrilleModel.java index 9da465f..be01ff9 100644 --- a/projetAgile/src/fr/iutfbleau/projetAgile/Model/GrilleModel.java +++ b/projetAgile/src/fr/iutfbleau/projetAgile/Model/GrilleModel.java @@ -126,7 +126,7 @@ public class GrilleModel extends AbstractGridInitiater{ public void switchPlayer() { int oldPlayer = this.playerTurn; - this.playerTurn = (this.playerTurn + 1) % 2; + this.playerTurn = this.playerTurn == Constants.PLAYER_ONE ? Constants.PLAYER_TWO : Constants.PLAYER_ONE; firePlayerChanged(oldPlayer, this.playerTurn); } diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/Utils/Constants.java b/projetAgile/src/fr/iutfbleau/projetAgile/Utils/Constants.java index 24bf6d8..4203bcf 100644 --- a/projetAgile/src/fr/iutfbleau/projetAgile/Utils/Constants.java +++ b/projetAgile/src/fr/iutfbleau/projetAgile/Utils/Constants.java @@ -8,9 +8,9 @@ public class Constants { public final static Color PLAYER_TWO_COLOR = new Color(241,205,15); public final static Color BACKGROUND_COLOR = new Color(31,31,31); public final static Color EMPTY_COLOR = new Color(42,42,42); - public final static int EMPTY_PLAYER = -1; - public final static int PLAYER_ONE = 0; - public final static int PLAYER_TWO = 1; + public final static int EMPTY_PLAYER = 0; + public final static int PLAYER_ONE = 1; + public final static int PLAYER_TWO = 2; public static int PIECE_MARGIN = 10; public static int COLUMN_COUNT = 7; public static int ROW_COUNT = 6; diff --git a/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java b/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java index b19bac5..97f29b6 100644 --- a/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java +++ b/projetAgile/src/fr/iutfbleau/projetAgile/View/Puissance4Panel.java @@ -108,7 +108,6 @@ public class Puissance4Panel extends JPanel{ public void changeLabel(int joueur) { switch(joueur){ - case Constants.PLAYER_ONE: this.label.setText("Tour Joueur 1"); break;