diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ba388b8..e9be677 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -12,8 +12,6 @@ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # - -#Thu Oct 03 19:38:30 CLST 2019 distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists diff --git a/src/main/java/cl/cromer/azaraka/Azaraka.java b/src/main/java/cl/cromer/azaraka/Azaraka.java index c85f3e9..086655e 100644 --- a/src/main/java/cl/cromer/azaraka/Azaraka.java +++ b/src/main/java/cl/cromer/azaraka/Azaraka.java @@ -22,14 +22,14 @@ import java.util.logging.Logger; * The main class of the game */ public class Azaraka implements Constants { - /** - * The main window - */ - private MainWindow mainWindow; /** * The logger */ private final Logger logger; + /** + * The main window + */ + private MainWindow mainWindow; /** * The main game class @@ -39,6 +39,24 @@ public class Azaraka implements Constants { start(); } + /** + * Open the main window + * + * @param args The arguments passed to the application + */ + public static void main(String[] args) { + int validCells = (HORIZONTAL_CELLS - 2) * (VERTICAL_CELLS - 2); + validCells = validCells - ENEMIES; + validCells = validCells - (CHESTS * 2); + validCells = validCells - OBSTACLES; + if (validCells < 10) { + // This is to prevent a possible infinite loop + System.out.println("Not enough valid cells: " + validCells + "!"); + System.exit(0); + } + new Azaraka(); + } + /** * Restart the game */ @@ -58,22 +76,4 @@ public class Azaraka implements Constants { mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } - /** - * Open the main window - * - * @param args The arguments passed to the application - */ - public static void main(String[] args) { - int validCells = (HORIZONTAL_CELLS - 2) * (VERTICAL_CELLS - 2); - validCells = validCells - ENEMIES; - validCells = validCells - (CHESTS * 2); - validCells = validCells - OBSTACLES; - if (validCells < 10) { - // This is to prevent a possible infinite loop - System.out.println("Not enough valid cells: " + validCells + "!"); - System.exit(0); - } - new Azaraka(); - } - } \ No newline at end of file diff --git a/src/main/java/cl/cromer/azaraka/Canvas.java b/src/main/java/cl/cromer/azaraka/Canvas.java index d44a956..623346f 100644 --- a/src/main/java/cl/cromer/azaraka/Canvas.java +++ b/src/main/java/cl/cromer/azaraka/Canvas.java @@ -80,6 +80,18 @@ public class Canvas extends java.awt.Canvas implements Constants { * The game over animation */ private final Animation gameOverAnimation; + /** + * The left margin of the game + */ + private final int leftMargin; + /** + * The top margin of the game + */ + private final int topMargin; + /** + * The threads that control AI + */ + private final HashMap aiThreads = new HashMap<>(); /** * The graphics buffer */ @@ -100,14 +112,6 @@ public class Canvas extends java.awt.Canvas implements Constants { * The hearts animation */ private Animation heartAnimation; - /** - * The left margin of the game - */ - private final int leftMargin; - /** - * The top margin of the game - */ - private final int topMargin; /** * The game scene */ @@ -152,10 +156,6 @@ public class Canvas extends java.awt.Canvas implements Constants { * The sound of the door opening or closing */ private Sound doorSound; - /** - * The threads that control AI - */ - private final HashMap aiThreads = new HashMap<>(); /** * The sound when a gem is received */ @@ -173,8 +173,8 @@ public class Canvas extends java.awt.Canvas implements Constants { * Initialize the canvas * * @param azaraka The main window - * @param width The width to set the canvas - * @param height The width to set the canvas + * @param width The width to set the canvas + * @param height The width to set the canvas */ public Canvas(Azaraka azaraka, int width, int height) { logger = getLogger(this.getClass(), LogLevel.LIENZO); diff --git a/src/main/java/cl/cromer/azaraka/ai/BreadthFirstSearch.java b/src/main/java/cl/cromer/azaraka/ai/BreadthFirstSearch.java index 45cff15..1cecf21 100644 --- a/src/main/java/cl/cromer/azaraka/ai/BreadthFirstSearch.java +++ b/src/main/java/cl/cromer/azaraka/ai/BreadthFirstSearch.java @@ -60,7 +60,7 @@ public class BreadthFirstSearch extends AI { /** * Find a path to the objective * - * @param searchInitial The start point + * @param searchInitial The start point * @param searchObjective The objective * @return Returns true if a path was found or false otherwise */ @@ -217,8 +217,8 @@ public class BreadthFirstSearch extends AI { * This method is called when the player arrives at a destination * * @param objective The objective the player arrived at - * @throws AIException Thrown if the method is called via super * @return Returns true if the destination condition is valid or false otherwise + * @throws AIException Thrown if the method is called via super */ protected boolean destinationArrived(State objective) throws AIException { String methodName = new Throwable().getStackTrace()[0].getMethodName(); diff --git a/src/main/java/cl/cromer/azaraka/ai/PlayerAI.java b/src/main/java/cl/cromer/azaraka/ai/PlayerAI.java index 540bf4c..af0515d 100644 --- a/src/main/java/cl/cromer/azaraka/ai/PlayerAI.java +++ b/src/main/java/cl/cromer/azaraka/ai/PlayerAI.java @@ -39,8 +39,8 @@ public class PlayerAI extends BreadthFirstSearch implements Constants { /** * Initialize the algorithm * - * @param scene The scene the AI is in - * @param player The player controlled by the AI + * @param scene The scene the AI is in + * @param player The player controlled by the AI */ public PlayerAI(Scene scene, Player player) { super(); diff --git a/src/main/java/cl/cromer/azaraka/object/Chest.java b/src/main/java/cl/cromer/azaraka/object/Chest.java index c0d82cc..dbd250e 100644 --- a/src/main/java/cl/cromer/azaraka/object/Chest.java +++ b/src/main/java/cl/cromer/azaraka/object/Chest.java @@ -50,7 +50,7 @@ public class Chest extends Object implements Constants { * Initialize the chest * * @param scene The scene the chest is in - * @param cell The cell that contains the chest + * @param cell The cell that contains the chest */ public Chest(Scene scene, Cell cell) { super(scene, cell); diff --git a/src/main/java/cl/cromer/azaraka/object/Enemy.java b/src/main/java/cl/cromer/azaraka/object/Enemy.java index c54a561..8280fae 100644 --- a/src/main/java/cl/cromer/azaraka/object/Enemy.java +++ b/src/main/java/cl/cromer/azaraka/object/Enemy.java @@ -47,8 +47,8 @@ public class Enemy extends Object implements Constants { * Initialize the enemy * * @param scene The scene the enemy is in - * @param cell The cell this enemy is in - * @param lock The lock used to prevent the threads from conflicting + * @param cell The cell this enemy is in + * @param lock The lock used to prevent the threads from conflicting */ public Enemy(Scene scene, Cell cell, Lock lock) { super(scene, cell); diff --git a/src/main/java/cl/cromer/azaraka/object/Gem.java b/src/main/java/cl/cromer/azaraka/object/Gem.java index 80cdacd..82c96a0 100644 --- a/src/main/java/cl/cromer/azaraka/object/Gem.java +++ b/src/main/java/cl/cromer/azaraka/object/Gem.java @@ -47,7 +47,7 @@ public class Gem extends Object { * Initialize the gem object * * @param scene The scene the gem is in - * @param cell The cell the gem is in + * @param cell The cell the gem is in */ public Gem(Scene scene, Cell cell) { super(scene, cell); diff --git a/src/main/java/cl/cromer/azaraka/object/Key.java b/src/main/java/cl/cromer/azaraka/object/Key.java index 260cbe7..38cc40b 100644 --- a/src/main/java/cl/cromer/azaraka/object/Key.java +++ b/src/main/java/cl/cromer/azaraka/object/Key.java @@ -42,7 +42,7 @@ public class Key extends Object implements Constants { * Initialize the key * * @param scene The scene the key is in - * @param cell The cell the key is in + * @param cell The cell the key is in */ public Key(Scene scene, Cell cell) { super(scene, cell); diff --git a/src/main/java/cl/cromer/azaraka/object/Object.java b/src/main/java/cl/cromer/azaraka/object/Object.java index ac61a8e..bd2a283 100644 --- a/src/main/java/cl/cromer/azaraka/object/Object.java +++ b/src/main/java/cl/cromer/azaraka/object/Object.java @@ -76,7 +76,7 @@ public class Object implements Runnable, Constants { * Initialize the object * * @param scene The scene the object is in - * @param cell The cell the object is in + * @param cell The cell the object is in */ protected Object(Scene scene, Cell cell) { this.scene = scene; diff --git a/src/main/java/cl/cromer/azaraka/object/Obstacle.java b/src/main/java/cl/cromer/azaraka/object/Obstacle.java index f653c79..b931200 100644 --- a/src/main/java/cl/cromer/azaraka/object/Obstacle.java +++ b/src/main/java/cl/cromer/azaraka/object/Obstacle.java @@ -26,7 +26,7 @@ public class Obstacle extends Object { * Initialize the obstacle * * @param scene The scene the object is in - * @param cell The cell the object is in + * @param cell The cell the object is in */ public Obstacle(Scene scene, Cell cell) { super(scene, cell); diff --git a/src/main/java/cl/cromer/azaraka/object/Player.java b/src/main/java/cl/cromer/azaraka/object/Player.java index bf19765..463453f 100644 --- a/src/main/java/cl/cromer/azaraka/object/Player.java +++ b/src/main/java/cl/cromer/azaraka/object/Player.java @@ -37,20 +37,20 @@ public class Player extends Object implements Constants { * Objects that the player is carrying */ private final ArrayList carrying = new ArrayList<>(); - /** - * The current health of the player - */ - private int health = MAX_HEALTH; /** * The artificial intelligence of the player */ private final PlayerAI ai; + /** + * The current health of the player + */ + private int health = MAX_HEALTH; /** * Initialize the player * * @param scene The scene the player is in - * @param cell The cell the player is in + * @param cell The cell the player is in */ public Player(Scene scene, Cell cell) { super(scene, cell); diff --git a/src/main/java/cl/cromer/azaraka/object/Portal.java b/src/main/java/cl/cromer/azaraka/object/Portal.java index c488fba..f7ea7f7 100644 --- a/src/main/java/cl/cromer/azaraka/object/Portal.java +++ b/src/main/java/cl/cromer/azaraka/object/Portal.java @@ -50,7 +50,7 @@ public class Portal extends Object implements Constants { * Initialize the portal * * @param scene The scene that contains the portal - * @param cell The cell the portal is in + * @param cell The cell the portal is in */ public Portal(Scene scene, Cell cell) { super(scene, cell); @@ -141,6 +141,15 @@ public class Portal extends Object implements Constants { } } + /** + * Get the current state of the portal + * + * @return Returns the state of the portal + */ + public State getState() { + return state; + } + /** * Sets a new status for the portal * @@ -179,15 +188,6 @@ public class Portal extends Object implements Constants { } } - /** - * Get the current state of the portal - * - * @return Returns the state of the portal - */ - public State getState() { - return state; - } - /** * This method is run when the thread starts */