fusion des branches
This commit is contained in:
commit
a809d51803
@ -14,7 +14,8 @@ Utils = build/$(PACKAGE_PATH)/Puissance4/Utils/Constants.class \
|
||||
|
||||
Events = build/$(PACKAGE_PATH)/Puissance4/Event/GridChangedListener.class \
|
||||
build/$(PACKAGE_PATH)/Puissance4/Event/GridEvent.class \
|
||||
build/$(PACKAGE_PATH)/Puissance4/Event/StatusEvent.class
|
||||
build/$(PACKAGE_PATH)/Puissance4/Event/StatusEvent.class \
|
||||
build/$(PACKAGE_PATH)/Puissance4/Event/PlayerEvent.class
|
||||
|
||||
Model = build/$(PACKAGE_PATH)/Puissance4/Model/GrilleModel.class
|
||||
|
||||
@ -45,6 +46,9 @@ build/$(PACKAGE_PATH)/Puissance4/Event/AbstractGridInitiater.class : src/$(PACKA
|
||||
$(Events)
|
||||
@javac $(@JAVAC_OPT) $<
|
||||
|
||||
build/$(PACKAGE_PATH)/Puissance4/Event/PlayerEvent.class : src/$(PACKAGE_PATH)/Puissance4/Event/PlayerEvent.java
|
||||
@javac $(@JAVAC_OPT) $<
|
||||
|
||||
#------- Controleur ------
|
||||
|
||||
build/$(PACKAGE_PATH)/Menu/Controleur/ObservateurAccueil.class : src/$(PACKAGE_PATH)/Menu/Controller/ObservateurAccueil.java
|
||||
|
BIN
projetAgile/res/mariadb-client.jar
Normal file
BIN
projetAgile/res/mariadb-client.jar
Normal file
Binary file not shown.
@ -66,6 +66,7 @@ public class BoutonsMenu extends JComponent{
|
||||
}else{
|
||||
secondPinceau.drawImage(this.img, 0, 0, this.getWidth(), this.getHeight(), this);
|
||||
secondPinceau.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), this.getWidth()/100*9, this.getHeight()/100*29);
|
||||
|
||||
}
|
||||
secondPinceau.setColor(new Color(255, 255, 255));
|
||||
secondPinceau.setFont(new Font(Font.SANS_SERIF, Font.BOLD, (this.getWidth()/10)));
|
||||
|
@ -29,4 +29,9 @@ public class ModelEventListener implements GridChangedListener {
|
||||
this.panel.changeHoverColor(e.getPlayerTurn());
|
||||
this.panel.setGameStatus(e.getStatus(), e.getPlayerTurn(), e.getPlayerOneScore(), e.getPlayerTwoScore(), e.getPlayerThreeScore());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerRemove(PlayerEvent e){
|
||||
this.panel.RemovePlayer(e.getJ(), e.getGrille());
|
||||
}
|
||||
}
|
||||
|
@ -64,4 +64,14 @@ public abstract class AbstractGridInitiater {
|
||||
listener.statusChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
protected void firePlayerChanged(int playerRemove, int[][] grille){
|
||||
PlayerEvent event=null;
|
||||
for(GridChangedListener listener : getGridListeners()) {
|
||||
if(event == null)
|
||||
event= new PlayerEvent(playerRemove, grille);
|
||||
listener.playerRemove(event);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,11 @@ public interface GridChangedListener extends EventListener{
|
||||
* @param e Evenement contenant les informations sur le status du jeu
|
||||
*/
|
||||
void statusChanged(StatusEvent e);
|
||||
|
||||
/**
|
||||
* Méthode invoqué lors de la suppréssion d'un joueur
|
||||
* @param e evenement du joueur a supprimé
|
||||
*/
|
||||
void playerRemove(PlayerEvent e);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package fr.iutfbleau.projetAgile.Puissance4.Event;
|
||||
|
||||
/**
|
||||
* evénement lors de la supprésion d'un joueur
|
||||
*/
|
||||
public class PlayerEvent {
|
||||
private int J;
|
||||
private int[][] grille;
|
||||
|
||||
public PlayerEvent(int j0, int[][] grille0){
|
||||
this.J=j0;
|
||||
this.grille=grille0;
|
||||
}
|
||||
public int getJ() {
|
||||
return J;
|
||||
}
|
||||
|
||||
public int[][] getGrille() {
|
||||
return grille;
|
||||
}
|
||||
}
|
@ -193,7 +193,7 @@ public class GrilleModel extends AbstractGridInitiater{
|
||||
*/
|
||||
public void setPartyStatus(GameStatus gameStatus) {
|
||||
this.gameStatus = gameStatus;
|
||||
if(gameStatus == GameStatus.WIN) {
|
||||
if(gameStatus == GameStatus.WIN || gameStatus == GameStatus.FIRST) {
|
||||
if(this.playerTurn == Constants.PLAYER_ONE)
|
||||
playerOneScore++;
|
||||
else if(this.playerTurn == Constants.PLAYER_TWO)
|
||||
@ -201,7 +201,38 @@ public class GrilleModel extends AbstractGridInitiater{
|
||||
else
|
||||
playerThreeScore++;
|
||||
}
|
||||
|
||||
fireStatusChanged(this.gameStatus, this.playerTurn, this.playerOneScore, this.playerTwoScore, this.playerThreeScore);
|
||||
if(this.gameStatus==GameStatus.FIRST){
|
||||
this.removePlayerPion();
|
||||
firePlayerChanged(this.playerTurn, this.grille);
|
||||
this.gameStatus=GameStatus.PLAYING;
|
||||
fireStatusChanged(this.gameStatus, this.playerTurn, this.playerOneScore, this.playerTwoScore, this.playerThreeScore);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* retire les pions du joueur qui viens de gagner
|
||||
*/
|
||||
private void removePlayerPion(){
|
||||
for(int i=0; i<this.grille.length; i++){
|
||||
for(int t=0; t<this.grille[i].length; t++){
|
||||
if(this.grille[i][t] == this.playerTurn ){
|
||||
this.dropColumn(this.grille[i], t);
|
||||
this.piecePlayed--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void dropColumn(int[] col, int ligne){
|
||||
for(int i=ligne; i>=0; i--){
|
||||
if(i>0){
|
||||
col[i]=col[i-1];
|
||||
}else{
|
||||
col[0]=Constants.EMPTY_PLAYER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ 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
|
||||
*/
|
||||
|
@ -81,6 +81,18 @@ public class Grille extends JPanel{
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
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]);
|
||||
this.grille[x][y].setHover(false);
|
||||
}
|
||||
}
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Change la couleur de survol des pions selon le tour du joueur
|
||||
* @param player le joueur qui joue
|
||||
@ -137,4 +149,8 @@ public class Grille extends JPanel{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removePlayerPion(int Joueur){
|
||||
|
||||
}
|
||||
}
|
@ -221,6 +221,10 @@ 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;
|
||||
@ -231,6 +235,12 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de définir le nom du joueur 1
|
||||
* @param playerOneName le nom du joueur
|
||||
|
Loading…
Reference in New Issue
Block a user