diff --git a/server/src/main/java/fr/lnl/game/server/games/Game.java b/server/src/main/java/fr/lnl/game/server/games/Game.java index 0251e89..8800e63 100644 --- a/server/src/main/java/fr/lnl/game/server/games/Game.java +++ b/server/src/main/java/fr/lnl/game/server/games/Game.java @@ -1,10 +1,7 @@ package fr.lnl.game.server.games; import fr.lnl.game.server.games.grid.Grid; -import fr.lnl.game.server.games.player.ComputerPlayer; import fr.lnl.game.server.games.player.Player; -import fr.lnl.game.server.games.weapon.Firearm; -import fr.lnl.game.server.utils.Point; public class Game { @@ -12,12 +9,13 @@ public class Game { Player player_One; Player player_Two; Player current_player; - Player[] players = {player_One,player_Two}; + Player[] players; public Game(Grid grid, Player player_One, Player player_Two){ this.player_One = player_One; this.player_Two = player_Two; this.current_player = player_One; + players = new Player[]{player_One, player_Two}; } diff --git a/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java b/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java index a40e373..9a0e4a9 100644 --- a/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java +++ b/server/src/main/java/fr/lnl/game/server/games/grid/Grid.java @@ -8,7 +8,7 @@ import java.util.HashMap; public class Grid { - private HashMap, Triplet> board; + private HashMap> board; private int x; private int y; @@ -41,7 +41,7 @@ public class Grid { } else { box = null; } - board.put(new Point(i,j),new Triplet(box,null,null)); + board.put(new Point(i,j), new Triplet<>(box, null, null)); } } } @@ -51,7 +51,7 @@ public class Grid { for (int i = 0; i < x; i++) { System.out.print("\n"); for (int j = 0; j < y; j++) { - Triplet value = board.get(new Point(i, j)); + Triplet value = board.get(new Point(i, j)); if (value.getA() instanceof Wall) { if (((Wall) value.getA()).getCardinal() == Cardinal.NORTH) { System.out.print(" \033[0;34m—\033[0m"); diff --git a/server/src/main/java/fr/lnl/game/server/utils/Pair.java b/server/src/main/java/fr/lnl/game/server/utils/Pair.java new file mode 100644 index 0000000..d5d9b57 --- /dev/null +++ b/server/src/main/java/fr/lnl/game/server/utils/Pair.java @@ -0,0 +1,35 @@ +package fr.lnl.game.server.utils; + +import java.util.Objects; + +public class Pair { + + private X x; + private Y y; + + public Pair(X x, Y y){ + this.x = x; + this.y = y; + } + + public X getX() { + return this.x; + } + + public Y getY() { + return y; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pair point = (Pair) o; + return Objects.equals(x, point.x) && Objects.equals(y, point.y); + } + + @Override + public int hashCode() { + return Objects.hash(x, y); + } +} diff --git a/server/src/main/java/fr/lnl/game/server/utils/Point.java b/server/src/main/java/fr/lnl/game/server/utils/Point.java index ebb35d3..2091450 100644 --- a/server/src/main/java/fr/lnl/game/server/utils/Point.java +++ b/server/src/main/java/fr/lnl/game/server/utils/Point.java @@ -1,46 +1,9 @@ package fr.lnl.game.server.utils; -import java.util.Objects; +public class Point extends Pair { -public class Point { - - private X x; - private Y y; - public Point(X x, Y y){ - this.x = x; - this.y = y; + public Point(int a, int b) { + super(a, b); } - public Point(){ - this(null, null); - } - - public X getX() { - return this.x; - } - - public Y getY() { - return y; - } - - public void setX(X x) { - this.x = x; - } - - public void setY(Y y) { - this.y = y; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Point point = (Point) o; - return Objects.equals(x, point.x) && Objects.equals(y, point.y); - } - - @Override - public int hashCode() { - return Objects.hash(x, y); - } }