VIctoire etc
This commit is contained in:
parent
b7eb8af07f
commit
189960c750
@ -16,7 +16,8 @@ Utils = build/$(PACKAGE_PATH)/Utils/Constants.class \
|
||||
|
||||
Events = build/$(PACKAGE_PATH)/Event/GridChangedListener.class \
|
||||
build/$(PACKAGE_PATH)/Event/GridEvent.class \
|
||||
build/$(PACKAGE_PATH)/Event/PlayerEvent.class
|
||||
build/$(PACKAGE_PATH)/Event/PlayerEvent.class \
|
||||
build/$(PACKAGE_PATH)/Event/StatusEvent.class
|
||||
|
||||
Model = build/$(PACKAGE_PATH)/Model/GrilleModel.class
|
||||
|
||||
@ -36,6 +37,10 @@ build/$(PACKAGE_PATH)/Event/PlayerEvent.class : src/$(PACKAGE_PATH)/Event/Player
|
||||
build/$(PACKAGE_PATH)/Event/GridEvent.class : src/$(PACKAGE_PATH)/Event/GridEvent.java
|
||||
javac $(JAVAC_OPT) $<
|
||||
|
||||
build/$(PACKAGE_PATH)/Event/StatusEvent.class : src/$(PACKAGE_PATH)/Event/StatusEvent.java \
|
||||
build/$(PACKAGE_PATH)/Utils/GameStatus.class
|
||||
javac $(JAVAC_OPT) $<
|
||||
|
||||
build/$(PACKAGE_PATH)/Event/GridChangedListener.class : src/$(PACKAGE_PATH)/Event/GridChangedListener.java \
|
||||
build/$(PACKAGE_PATH)/Event/GridEvent.class \
|
||||
build/$(PACKAGE_PATH)/Event/PlayerEvent.class
|
||||
|
@ -23,7 +23,6 @@ public class ModelEventListener implements GridChangedListener {
|
||||
|
||||
@Override
|
||||
public void statusChanged(StatusEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
this.panel.setGameStatus(e.getStatus(), e.getPlayerTurn());
|
||||
}
|
||||
}
|
||||
|
@ -63,11 +63,11 @@ public abstract class AbstractGridInitiater {
|
||||
* Notifie tous les listeners lorsque le status du jeu change
|
||||
* @param status Le nouveau status
|
||||
*/
|
||||
protected void fireStatusChanged(GameStatus status) {
|
||||
protected void fireStatusChanged(GameStatus status, int playerTurn) {
|
||||
StatusEvent event = null;
|
||||
for(GridChangedListener listener : getGridListeners()) {
|
||||
if(event == null)
|
||||
event = new StatusEvent(status);
|
||||
event = new StatusEvent(status, playerTurn);
|
||||
listener.statusChanged(event);
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,13 @@ import fr.iutfbleau.projetAgile.Utils.GameStatus;
|
||||
|
||||
public class StatusEvent {
|
||||
private GameStatus status;
|
||||
|
||||
private int playerTurn;
|
||||
/**
|
||||
* Evenement représentant le changement dans la grille
|
||||
* @param column la colonne modifié
|
||||
* @param row la ligne modifié
|
||||
* @param player le joueur qui a joué
|
||||
* Evenement représentant le changement de status du jeu
|
||||
*/
|
||||
public StatusEvent(GameStatus status) {
|
||||
public StatusEvent(GameStatus status, int playerTurn) {
|
||||
this.status = status;
|
||||
this.playerTurn = playerTurn;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,4 +20,8 @@ public class StatusEvent {
|
||||
public GameStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public int getPlayerTurn() {
|
||||
return this.playerTurn;
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class GrilleModel extends AbstractGridInitiater{
|
||||
|
||||
public void setPartyStatus(GameStatus gameStatus) {
|
||||
this.gameStatus = gameStatus;
|
||||
fireStatusChanged(this.gameStatus);
|
||||
fireStatusChanged(this.gameStatus, this.playerTurn);
|
||||
}
|
||||
|
||||
public GameStatus getGameStatus() {
|
||||
|
@ -6,6 +6,7 @@ import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionListener;
|
||||
import fr.iutfbleau.projetAgile.Utils.Constants;
|
||||
import fr.iutfbleau.projetAgile.Utils.GameStatus;
|
||||
|
||||
public class Puissance4Panel extends JPanel{
|
||||
|
||||
@ -125,5 +126,23 @@ public class Puissance4Panel extends JPanel{
|
||||
public void addPlayerPiece(int column, int row, int player) {
|
||||
this.grille.addPlayerPiece(column, row, player);
|
||||
}
|
||||
|
||||
public void setGameStatus(GameStatus status, int playerTurn) {
|
||||
this.grille.hover(-1, playerTurn);
|
||||
switch(status){
|
||||
case STOP:
|
||||
this.label.setText("Victoire du joueur " + playerTurn);
|
||||
break;
|
||||
|
||||
case DRAW:
|
||||
this.label.setText("Egalité");
|
||||
break;
|
||||
|
||||
default:
|
||||
this.changeLabel(playerTurn);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user