From 2e99366e5646348bcde7f189d0b8df3cdd72d2db Mon Sep 17 00:00:00 2001 From: Katchan <35238981+KatchanNve@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:52:12 +0100 Subject: [PATCH] Add utils functions --- .../main/java/fr/lnl/game/server/games/action/Action.java | 1 + .../java/fr/lnl/game/server/games/action/DeployShield.java | 5 +++++ .../java/fr/lnl/game/server/games/action/DropObject.java | 4 ++++ .../src/main/java/fr/lnl/game/server/games/action/Move.java | 6 ++++++ .../main/java/fr/lnl/game/server/games/action/Nothing.java | 5 +++++ .../java/fr/lnl/game/server/games/player/HumanPlayer.java | 4 ++++ 6 files changed, 25 insertions(+) diff --git a/server/src/main/java/fr/lnl/game/server/games/action/Action.java b/server/src/main/java/fr/lnl/game/server/games/action/Action.java index 325caa4..9179e65 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/Action.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/Action.java @@ -22,6 +22,7 @@ public interface Action { * Used by {@link Move}, {@link Shot} and {@link DropObject} to list all direction when the action is possible * @return a list a point where the action is possible (not block by a wall per example) */ + Point getPoint(); List getValidPoint(); } diff --git a/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java b/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java index 955812f..ffc67df 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/DeployShield.java @@ -32,6 +32,11 @@ public class DeployShield extends AbstractAction { return true; } + @Override + public Point getPoint() { + return null; + } + @Override public List getValidPoint() { return null; diff --git a/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java b/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java index e6f123b..6c56332 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/DropObject.java @@ -71,4 +71,8 @@ public abstract class DropObject extends AbstractAction { return direction; } + @Override + public Point getPoint() { + return point; + } } diff --git a/server/src/main/java/fr/lnl/game/server/games/action/Move.java b/server/src/main/java/fr/lnl/game/server/games/action/Move.java index 597cf1c..88d2a0c 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/Move.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/Move.java @@ -60,6 +60,7 @@ public class Move extends AbstractAction { * We add a point to the list where there is nothing on the board. * @see Action#getValidPoint() */ + @Override public List getValidPoint() { List listMoves = new ArrayList<>(); @@ -81,6 +82,11 @@ public class Move extends AbstractAction { return listMoves; } + @Override + public Point getPoint() { + return point; + } + public Direction getDirection() { return direction; } diff --git a/server/src/main/java/fr/lnl/game/server/games/action/Nothing.java b/server/src/main/java/fr/lnl/game/server/games/action/Nothing.java index c6c2b20..1157815 100644 --- a/server/src/main/java/fr/lnl/game/server/games/action/Nothing.java +++ b/server/src/main/java/fr/lnl/game/server/games/action/Nothing.java @@ -29,6 +29,11 @@ public class Nothing extends AbstractAction { return true; } + @Override + public Point getPoint() { + return null; + } + @Override public List getValidPoint() { return null; 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 a5ff86d..5cc31b8 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 @@ -9,4 +9,8 @@ public class HumanPlayer extends AbstractPlayer { } + @Override + public String toString() { + return "Human"; + } }