diff --git a/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java index d3bc8d0..b2d7903 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/AbstractPlayer.java @@ -7,14 +7,14 @@ public abstract class AbstractPlayer { private int id; private Point position; - private int ernergy; + private int energy; private Weapon weapon; private boolean shieldDeploy; - public AbstractPlayer(int id, Point position, int ernergy, Weapon weapon, boolean shieldDeploy) { + public AbstractPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) { this.id = id; this.position = position; - this.ernergy = ernergy; + this.energy = energy; this.weapon = weapon; this.shieldDeploy = shieldDeploy; } @@ -31,8 +31,8 @@ public abstract class AbstractPlayer { return position; } - public int getErnergy() { - return ernergy; + public int getEnergy() { + return energy; } public Weapon getWeapon() { @@ -43,8 +43,8 @@ public abstract class AbstractPlayer { return shieldDeploy; } - public void setErnergy(int ernergy) { - this.ernergy = ernergy; + public void setEnergy(int energy) { + this.energy = energy; } public void setPosition(Point position) { diff --git a/server/src/main/java/fr/lnl/game/server/model/AbstractModelListening.java b/server/src/main/java/fr/lnl/game/server/model/AbstractModelListening.java new file mode 100644 index 0000000..310daab --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/model/AbstractModelListening.java @@ -0,0 +1,14 @@ +package fr.lnl.game.server.model; +import java.util.List; + +public abstract class AbstractModelListening implements ModelListener{ + List listeners; + public abstract void addListener(ModelListener e); + public abstract void removalListener(ModelListener e); + public void fireChange(){ + for(ModelListener e : listeners){ + e.updateModel(this); + } + } + +} diff --git a/server/src/main/java/fr/lnl/game/server/model/ModelListener.java b/server/src/main/java/fr/lnl/game/server/model/ModelListener.java new file mode 100644 index 0000000..4751679 --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/model/ModelListener.java @@ -0,0 +1,6 @@ +package fr.lnl.game.server.model; + +public interface ModelListener { + //à peut-être revoir + void updateModel(Object obj); +} diff --git a/server/src/main/java/fr/lnl/game/server/model/ModelListening.java b/server/src/main/java/fr/lnl/game/server/model/ModelListening.java new file mode 100644 index 0000000..12128b7 --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/model/ModelListening.java @@ -0,0 +1,21 @@ +package fr.lnl.game.server.model; + +public class ModelListening extends AbstractModelListening{ + + + @Override + public void addListener(ModelListener e) { + this.listeners.add(e); + } + + @Override + public void removalListener(ModelListener e) { + this.listeners.remove(e); + } + + + @Override + public void updateModel(Object obj) { + + } +}