diff --git a/server/src/main/java/fr/lnl/game/server/ServerMain.java b/server/src/main/java/fr/lnl/game/server/ServerMain.java index cc05ccf..52782d8 100644 --- a/server/src/main/java/fr/lnl/game/server/ServerMain.java +++ b/server/src/main/java/fr/lnl/game/server/ServerMain.java @@ -3,14 +3,14 @@ package fr.lnl.game.server; import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.games.player.ComputerPlayer; +import fr.lnl.game.server.games.player.DefaultClassPlayer; import fr.lnl.game.server.games.player.Player; -import fr.lnl.game.server.games.weapon.Firearm; public class ServerMain { public static void main(String[] args) { - Player playerOne = new ComputerPlayer(1,1000,new Firearm()); - Player playerTwo = new ComputerPlayer(2,1000,new Firearm()); + Player playerOne = new ComputerPlayer(1,new DefaultClassPlayer()); + Player playerTwo = new ComputerPlayer(2,new DefaultClassPlayer()); Grid grid = new Grid(16,16,new Player[]{playerOne,playerTwo}); grid.initGrid(); 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 55a2354..a5177d2 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 @@ -12,12 +12,14 @@ public abstract class AbstractPlayer implements Player { private Weapon weapon; private boolean shieldDeploy; private Action[] actions; + private ClassPlayer classPlayer; - public AbstractPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) { + public AbstractPlayer(int id, Point position, boolean shieldDeploy, ClassPlayer classPlayer) { this.id = id; this.position = position; - this.energy = energy; - this.weapon = weapon; + this.classPlayer = classPlayer; + this.energy = classPlayer.getEnergy(); + this.weapon = classPlayer.getWeapon(); this.shieldDeploy = shieldDeploy; } @@ -60,4 +62,12 @@ public abstract class AbstractPlayer implements Player { public void setWeapon(Weapon weapon) { this.weapon = weapon; } + + public Action[] getActions() { + return actions; + } + + public ClassPlayer getClassPlayer() { + return classPlayer; + } } diff --git a/server/src/main/java/fr/lnl/game/server/games/player/ClassPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/ClassPlayer.java new file mode 100644 index 0000000..b355ef8 --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/games/player/ClassPlayer.java @@ -0,0 +1,19 @@ +package fr.lnl.game.server.games.player; + +import fr.lnl.game.server.games.weapon.Weapon; +import fr.lnl.game.server.utils.Point; + +public interface ClassPlayer { + + int getEnergy(); + int getShieldCost(); + int getShootdCost(); + int getMineCost(); + int getBombCost(); + int getDeplaceCost(); + int getGainEnergyBall(); + int getPenaltyShoot(); + int getPenaltyMine(); + int getPenaltyBomb(); + Weapon getWeapon(); +} diff --git a/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java index 913962c..abcdf35 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/ComputerPlayer.java @@ -1,15 +1,14 @@ package fr.lnl.game.server.games.player; -import fr.lnl.game.server.games.weapon.Weapon; import fr.lnl.game.server.utils.Point; public class ComputerPlayer extends AbstractPlayer{ - public ComputerPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) { - super(id, position, energy, weapon, shieldDeploy); + public ComputerPlayer(int id, Point position, boolean shieldDeploy, ClassPlayer classPlayer) { + super(id, position, shieldDeploy, classPlayer); } - public ComputerPlayer(int id, int energy, Weapon weapon) { - super(id, null, energy, weapon, false); + public ComputerPlayer(int id, ClassPlayer classPlayer) { + super(id, null,false, classPlayer); } } diff --git a/server/src/main/java/fr/lnl/game/server/games/player/DefaultClassPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/DefaultClassPlayer.java new file mode 100644 index 0000000..10a0de4 --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/games/player/DefaultClassPlayer.java @@ -0,0 +1,78 @@ +package fr.lnl.game.server.games.player; + +import fr.lnl.game.server.games.weapon.Firearm; +import fr.lnl.game.server.games.weapon.Weapon; + +public class DefaultClassPlayer implements ClassPlayer{ + + private final int ENERGY = 800; + private final int SHIELDCOST = 25; + private final int SHOOTDCOST = 40; + private final int MINECOST = 30; + private final int BOMBCOST = 40; + private final int DEPLACECOST = 10; + private final int GAINENERGYBALL = 800; + private final int PENALTYSHOOT = 20; + private final int PENALTYBOMB = 20; + private final int PENALTYMINE = 15; + private final Weapon WEAPON = new Firearm(); + + + public DefaultClassPlayer(){ + } + + @Override + public int getEnergy() { + return this.ENERGY; + } + + @Override + public int getShieldCost() { + return this.SHIELDCOST; + } + + @Override + public int getShootdCost() { + return this.SHOOTDCOST; + } + + @Override + public int getMineCost() { + return this.MINECOST; + } + + @Override + public int getBombCost() { + return this.BOMBCOST; + } + + @Override + public int getDeplaceCost() { + return this.DEPLACECOST; + } + + @Override + public int getGainEnergyBall() { + return this.GAINENERGYBALL; + } + + @Override + public int getPenaltyShoot() { + return this.PENALTYSHOOT; + } + + @Override + public int getPenaltyMine() { + return this.PENALTYMINE; + } + + @Override + public int getPenaltyBomb() { + return this.PENALTYBOMB; + } + + @Override + public Weapon getWeapon() { + return this.WEAPON; + } +} diff --git a/server/src/main/java/fr/lnl/game/server/games/player/HumanPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/HumanPlayer.java index 90ce542..f2c840c 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/HumanPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/HumanPlayer.java @@ -4,7 +4,8 @@ import fr.lnl.game.server.games.weapon.Weapon; import fr.lnl.game.server.utils.Point; public class HumanPlayer extends AbstractPlayer { - public HumanPlayer(int id, Point position, int energy, Weapon weapon, boolean shieldDeploy) { - super(id, position, energy, weapon, shieldDeploy); + + public HumanPlayer(int id, Point position, boolean shieldDeploy, ClassPlayer classPlayer) { + super(id, position, shieldDeploy, classPlayer); } } diff --git a/server/src/main/java/fr/lnl/game/server/games/weapon/Firearm.java b/server/src/main/java/fr/lnl/game/server/games/weapon/Firearm.java index 26f596b..9885152 100644 --- a/server/src/main/java/fr/lnl/game/server/games/weapon/Firearm.java +++ b/server/src/main/java/fr/lnl/game/server/games/weapon/Firearm.java @@ -8,8 +8,8 @@ public class Firearm implements Weapon{ public Firearm(){ this.bullet = 10; - this.horizontalDistance = 10; - this.verticalDistance = 10; + this.horizontalDistance = 2; + this.verticalDistance = 3; }