This commit is contained in:
martins 2022-11-10 13:38:05 +01:00
commit f8e2cc7294
9 changed files with 18 additions and 20 deletions

View File

@ -1,5 +1,5 @@
@JAVAC_OPT = -implicit:none \
-d build -classpath "build" -sourcepath src
-d build -classpath "build:res/mariadb-client.jar" -sourcepath src
PACKAGE = fr.iutfbleau.projetAgile
PACKAGE_PATH = fr/iutfbleau/projetAgile

View File

@ -26,7 +26,7 @@ public class ColorChooserListener implements ChangeListener {
ColorSelectionModel chooser = (ColorSelectionModel) e.getSource();
if(this.player == Constants.PLAYER_ONE)
Constants.PLAYER_ONE_COLOR = chooser.getSelectedColor();
else if(this.player == Constants.PLAYER_THREE)
else if(this.player == Constants.PLAYER_TWO)
Constants.PLAYER_TWO_COLOR = chooser.getSelectedColor();
else
Constants.PLAYER_THREE_COLOR = chooser.getSelectedColor();

View File

@ -32,6 +32,6 @@ public class ModelEventListener implements GridChangedListener {
@Override
public void playerRemove(PlayerEvent e){
this.panel.RemovePlayer(e.getJ(), e.getGrille());
this.panel.removePlayer(e.getJ(), e.getGrille());
}
}

View File

@ -63,6 +63,10 @@ public class Puissance4Controller {
}
this.grille.reset();
this.modele.reset();
if(this.modele.getPlayerThreeName() != null) {
this.modele.setPlayerNumber(3);
this.panel.setPlayerNumber(3);
}
this.panel.changeHoverColor(this.modele.getPlayerTurn());
this.panel.changeLabel(this.modele.getPlayerTurn());
}
@ -73,7 +77,7 @@ public class Puissance4Controller {
* @see fr.iutfbleau.projetAgile.Puissance4.Model.GrilleModel#verifyColumn(int)
*/
public void verifyColumn(int x) {
if(this.modele.getGameStatus() == GameStatus.PLAYING || this.modele.getGameStatus() == GameStatus.FIRST) {
if(this.modele.getGameStatus() == GameStatus.PLAYING) {
int column = (x * this.modele.getColumn() / grille.getWidth());
this.modele.verifyColumn(column);
}
@ -85,7 +89,7 @@ public class Puissance4Controller {
* Si x est égal à -1 efface le survol
*/
public void hoverGrille(int x) {
if(this.modele.getGameStatus() == GameStatus.PLAYING || this.modele.getGameStatus() == GameStatus.FIRST) {
if(this.modele.getGameStatus() == GameStatus.PLAYING) {
if(x == -1) {
this.grille.hover(-1); //Clean
return;

View File

@ -176,7 +176,6 @@ public class GrilleModel extends AbstractGridInitiater{
this.playerThreeScore++;
break;
}
this.fireStatusChanged(GameStatus.FIRST, playerTurn, playerOneScore, playerTwoScore, playerThreeScore);
this.removePlayerPion();
this.firePlayerChanged(this.playerTurn, this.grille);
this.tour.pollLast();
@ -387,4 +386,8 @@ public class GrilleModel extends AbstractGridInitiater{
public void setPlayerThreeName(String playerThreeName) {
this.playerThreeName = playerThreeName;
}
public void setPlayerNumber(int i) {
this.playerNumber = i;
}
}

View File

@ -4,10 +4,6 @@ package fr.iutfbleau.projetAgile.Puissance4.Utils;
* Enumeration du status d'une partie (En cours, gagné, égalité)
*/
public enum GameStatus {
FIRST,
/**
* Status d'une partie en cours
*/
PLAYING,
/**
* Status d'une partie terminé et gagné par un joueur

View File

@ -87,7 +87,7 @@ public class ColorChooserDialog extends JDialog{
playerTwoChooser.getSelectionModel().addChangeListener(new ColorChooserListener(pionP2, Constants.PLAYER_TWO));
playerThreeChooser.getSelectionModel().addChangeListener(new ColorChooserListener(pionP2, Constants.PLAYER_THREE));
playerThreeChooser.getSelectionModel().addChangeListener(new ColorChooserListener(pionP3, Constants.PLAYER_THREE));
JPanel panelP1 = new JPanel(new GridBagLayout());

View File

@ -81,7 +81,7 @@ public class Grille extends JPanel{
this.repaint();
}
public void RemovePlayer(int Joueur, int[][] j){
public void removePlayer(int Joueur, int[][] j){
for (int x = 0; x < this.column; x++) {
for (int y = 0; y < this.row; y++) {
this.grille[x][y].setPlayer(j[x][y]);

View File

@ -221,10 +221,6 @@ public class Puissance4Panel extends JPanel{
this.playerTurn.setText("Egalité");
break;
case FIRST:
JOptionPane.showMessageDialog(this, "Victoire de : " + (playerTurn == Constants.PLAYER_ONE ? this.playerOneName : this.playerTwoName), "Victoire", JOptionPane.DEFAULT_OPTION);
break;
default:
this.changeLabel(playerTurn);
break;
@ -235,10 +231,9 @@ public class Puissance4Panel extends JPanel{
this.changeScore(playerOneScore, playerTwoScore, playerThreeScore);
}
public void RemovePlayer(int Player, int[][] grille){
this.grille.RemovePlayer(Player, grille);
this.changeHoverColor(Player);
this.changeLabel(Player);
public void removePlayer(int player, int[][] grille){
this.grille.removePlayer(player, grille);
JOptionPane.showMessageDialog(this, "Le joeur "+String.valueOf(player)+" a gagné");
}
/**