Cleanup code
Signed-off-by: Chris Cromer <chris@cromer.cl>
This commit is contained in:
parent
81432f3243
commit
000a5e1fde
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -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.
|
# 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
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
@ -22,14 +22,14 @@ import java.util.logging.Logger;
|
|||||||
* The main class of the game
|
* The main class of the game
|
||||||
*/
|
*/
|
||||||
public class Azaraka implements Constants {
|
public class Azaraka implements Constants {
|
||||||
/**
|
|
||||||
* The main window
|
|
||||||
*/
|
|
||||||
private MainWindow mainWindow;
|
|
||||||
/**
|
/**
|
||||||
* The logger
|
* The logger
|
||||||
*/
|
*/
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
/**
|
||||||
|
* The main window
|
||||||
|
*/
|
||||||
|
private MainWindow mainWindow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main game class
|
* The main game class
|
||||||
@ -39,6 +39,24 @@ public class Azaraka implements Constants {
|
|||||||
start();
|
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
|
* Restart the game
|
||||||
*/
|
*/
|
||||||
@ -58,22 +76,4 @@ public class Azaraka implements Constants {
|
|||||||
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -80,6 +80,18 @@ public class Canvas extends java.awt.Canvas implements Constants {
|
|||||||
* The game over animation
|
* The game over animation
|
||||||
*/
|
*/
|
||||||
private final Animation gameOverAnimation;
|
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<AI, Thread> aiThreads = new HashMap<>();
|
||||||
/**
|
/**
|
||||||
* The graphics buffer
|
* The graphics buffer
|
||||||
*/
|
*/
|
||||||
@ -100,14 +112,6 @@ public class Canvas extends java.awt.Canvas implements Constants {
|
|||||||
* The hearts animation
|
* The hearts animation
|
||||||
*/
|
*/
|
||||||
private Animation heartAnimation;
|
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
|
* The game scene
|
||||||
*/
|
*/
|
||||||
@ -152,10 +156,6 @@ public class Canvas extends java.awt.Canvas implements Constants {
|
|||||||
* The sound of the door opening or closing
|
* The sound of the door opening or closing
|
||||||
*/
|
*/
|
||||||
private Sound doorSound;
|
private Sound doorSound;
|
||||||
/**
|
|
||||||
* The threads that control AI
|
|
||||||
*/
|
|
||||||
private final HashMap<AI, Thread> aiThreads = new HashMap<>();
|
|
||||||
/**
|
/**
|
||||||
* The sound when a gem is received
|
* The sound when a gem is received
|
||||||
*/
|
*/
|
||||||
|
@ -217,8 +217,8 @@ public class BreadthFirstSearch extends AI {
|
|||||||
* This method is called when the player arrives at a destination
|
* This method is called when the player arrives at a destination
|
||||||
*
|
*
|
||||||
* @param objective The objective the player arrived at
|
* @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
|
* @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 {
|
protected boolean destinationArrived(State objective) throws AIException {
|
||||||
String methodName = new Throwable().getStackTrace()[0].getMethodName();
|
String methodName = new Throwable().getStackTrace()[0].getMethodName();
|
||||||
|
@ -37,14 +37,14 @@ public class Player extends Object implements Constants {
|
|||||||
* Objects that the player is carrying
|
* Objects that the player is carrying
|
||||||
*/
|
*/
|
||||||
private final ArrayList<Object> carrying = new ArrayList<>();
|
private final ArrayList<Object> carrying = new ArrayList<>();
|
||||||
/**
|
|
||||||
* The current health of the player
|
|
||||||
*/
|
|
||||||
private int health = MAX_HEALTH;
|
|
||||||
/**
|
/**
|
||||||
* The artificial intelligence of the player
|
* The artificial intelligence of the player
|
||||||
*/
|
*/
|
||||||
private final PlayerAI ai;
|
private final PlayerAI ai;
|
||||||
|
/**
|
||||||
|
* The current health of the player
|
||||||
|
*/
|
||||||
|
private int health = MAX_HEALTH;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the player
|
* Initialize the player
|
||||||
|
@ -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
|
* 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
|
* This method is run when the thread starts
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user