Pion avec antialiasing, code redondant classe PlayerEvent et StatusEvent --> Fusion des deux classes
This commit is contained in:
parent
189960c750
commit
f3dbdc38f8
@ -16,7 +16,6 @@ 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/StatusEvent.class
|
||||
|
||||
Model = build/$(PACKAGE_PATH)/Model/GrilleModel.class
|
||||
@ -31,9 +30,6 @@ ArgileGames.jar : build/$(PACKAGE_PATH)/Main.class
|
||||
|
||||
#------- Events ------
|
||||
|
||||
build/$(PACKAGE_PATH)/Event/PlayerEvent.class : src/$(PACKAGE_PATH)/Event/PlayerEvent.java
|
||||
javac $(JAVAC_OPT) $<
|
||||
|
||||
build/$(PACKAGE_PATH)/Event/GridEvent.class : src/$(PACKAGE_PATH)/Event/GridEvent.java
|
||||
javac $(JAVAC_OPT) $<
|
||||
|
||||
@ -42,8 +38,7 @@ build/$(PACKAGE_PATH)/Event/StatusEvent.class : src/$(PACKAGE_PATH)/Event/Status
|
||||
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
|
||||
build/$(PACKAGE_PATH)/Event/GridEvent.class
|
||||
javac $(JAVAC_OPT) $<
|
||||
|
||||
build/$(PACKAGE_PATH)/Event/AbstractGridInitiater.class : src/$(PACKAGE_PATH)/Event/AbstractGridInitiater.java \
|
||||
|
@ -17,8 +17,8 @@ public class ModelEventListener implements GridChangedListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerChanged(PlayerEvent e) {
|
||||
this.panel.changeLabel(e.getNewPlayer());
|
||||
public void playerChanged(StatusEvent e) {
|
||||
this.panel.changeLabel(e.getPlayerTurn());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,11 +50,11 @@ public abstract class AbstractGridInitiater {
|
||||
* @param oldPlayer L'ancien joueur qui jouait
|
||||
* @param newPlayer Le nouveau joueur qui joue
|
||||
*/
|
||||
protected void firePlayerChanged(int oldPlayer, int newPlayer) {
|
||||
PlayerEvent event = null;
|
||||
protected void firePlayerChanged(GameStatus status, int playerTurn) {
|
||||
StatusEvent event = null;
|
||||
for(GridChangedListener listener : getGridListeners()) {
|
||||
if(event == null)
|
||||
event = new PlayerEvent(oldPlayer, newPlayer);
|
||||
event = new StatusEvent(status, playerTurn);
|
||||
listener.playerChanged(event);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public interface GridChangedListener extends EventListener{
|
||||
* Méthode invoqué lorsque le tour du joueur est modifié
|
||||
* @param e Evenement contenant l'ancien joueur et le nouveau
|
||||
*/
|
||||
void playerChanged(PlayerEvent e);
|
||||
void playerChanged(StatusEvent e);
|
||||
|
||||
/**
|
||||
* Méthode invoqué lorsque le tour du joueur est modifié
|
||||
|
@ -1,32 +0,0 @@
|
||||
package fr.iutfbleau.projetAgile.Event;
|
||||
|
||||
public class PlayerEvent {
|
||||
|
||||
private int oldPlayer;
|
||||
private int newPlayer;
|
||||
/**
|
||||
* Evenement représentant le changement de tour des joueurs
|
||||
* @param oldPlayer l'ancien joueur
|
||||
* @param newPlayer le nouveau joueur
|
||||
*/
|
||||
public PlayerEvent(int oldPlayer, int newPlayer) {
|
||||
this.newPlayer = newPlayer;
|
||||
this.oldPlayer = oldPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le nouveau joueur
|
||||
* @return Le nouveau joueur
|
||||
*/
|
||||
public int getNewPlayer() {
|
||||
return newPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne l'ancien joueur
|
||||
* @return L'ancien joueur
|
||||
*/
|
||||
public int getOldPlayer() {
|
||||
return oldPlayer;
|
||||
}
|
||||
}
|
@ -126,9 +126,8 @@ public class GrilleModel extends AbstractGridInitiater{
|
||||
}
|
||||
|
||||
public void switchPlayer() {
|
||||
int oldPlayer = this.playerTurn;
|
||||
this.playerTurn = this.playerTurn == Constants.PLAYER_ONE ? Constants.PLAYER_TWO : Constants.PLAYER_ONE;
|
||||
firePlayerChanged(oldPlayer, this.playerTurn);
|
||||
firePlayerChanged(this.gameStatus, this.playerTurn);
|
||||
}
|
||||
|
||||
public int getPlayerTurn() {
|
||||
|
@ -47,7 +47,8 @@ public class Pion extends JComponent{
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
Graphics g2 = g.create();
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
Color c;
|
||||
switch(this.player) {
|
||||
case Constants.PLAYER_ONE :
|
||||
|
Loading…
Reference in New Issue
Block a user