-Created InvalidUpgradeException
-Implemented Maximum Number of Requested Objectives Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
651b6c2999
commit
7b0b2b666d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -235,6 +235,16 @@ public class DroneListItem {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returnes the list of all objectives this drone should be currently
|
||||
* looking for
|
||||
*
|
||||
* @return <code>ArrayList</code>
|
||||
*/
|
||||
public ArrayList<Objective> getCurrentObjectives() {
|
||||
return currentObjectives;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the drone is wanted
|
||||
*
|
||||
@ -322,6 +332,26 @@ public class DroneListItem {
|
||||
waiting += newWaiting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new objective to the list of current objectives
|
||||
*
|
||||
* @param newObj
|
||||
* Objective to add to list
|
||||
*/
|
||||
public void addObjective(Objective newObj) {
|
||||
currentObjectives.add(newObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an objective from the list of current objectives
|
||||
*
|
||||
* @param oldObj
|
||||
* Objective to remove from list
|
||||
*/
|
||||
public void removeObjective(Objective oldObj) {
|
||||
currentObjectives.remove(oldObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases the Visible Distance by specified amount
|
||||
*
|
||||
|
@ -3,7 +3,6 @@ package net.grosinger.nomads;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class Nomads {
|
||||
|
||||
public static World awesomeWorld;
|
||||
@ -47,7 +46,8 @@ public class Nomads {
|
||||
|
||||
public static final int MAXOBJECTIVEBOUNTY = 30;
|
||||
public static final int MINOBJECTIVEBOUNTY = 10;
|
||||
|
||||
public static final int MAXREQUESTEDOBJECTIVES = 2;
|
||||
|
||||
public static final int BASE_VISIBLEDISTANCE = 15;
|
||||
public static final int BASE_LUMALOCATORDISTANCE = 10;
|
||||
public static final int BASE_OBJECTLOCATORDISTANCE = 10;
|
||||
@ -57,7 +57,7 @@ public class Nomads {
|
||||
public static final int BASE_SPEED = 1;
|
||||
public static final int BASE_CARGOSPACE = 3;
|
||||
public static final int BASE_THEFT = 1;
|
||||
|
||||
|
||||
public static final int MAXLEVEL_RADARS = 30;
|
||||
public static final int MAXLEVEL_STATS = 10;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.grosinger.nomads;
|
||||
|
||||
import net.grosinger.nomads.exceptions.InsufficientFundsException;
|
||||
import net.grosinger.nomads.exceptions.InvalidUpgradeException;
|
||||
|
||||
/**
|
||||
* A representation of an UpgradeShop. Allows Drones to interact with this
|
||||
@ -12,8 +13,6 @@ public class UpgradeShop extends NeighborBuilding {
|
||||
super(x, y, name, building, drone);
|
||||
}
|
||||
|
||||
// TODO - Implement Upgrade Shop
|
||||
|
||||
/**
|
||||
* Performs an upgrade on the drone if it is possible. Must be passed an
|
||||
* upgrade that is not already of max level, and that has enough funds to
|
||||
@ -22,13 +21,19 @@ public class UpgradeShop extends NeighborBuilding {
|
||||
* @param toPerform
|
||||
* An Upgrade that should be performed
|
||||
* @throws InsufficientFundsException
|
||||
* @throws InvalidUpgradeException
|
||||
*/
|
||||
public void performUpgrade(Upgrade toPerform) throws InsufficientFundsException {
|
||||
public void performUpgrade(Upgrade toPerform) throws InsufficientFundsException,
|
||||
InvalidUpgradeException {
|
||||
int teamBalance = drone.getTeam().getBalance();
|
||||
int upgradeCost = toPerform.getPrice();
|
||||
|
||||
if (upgradeCost > teamBalance) {
|
||||
throw new InsufficientFundsException();
|
||||
} else if (toPerform.isMaxLevel()) {
|
||||
throw new InvalidUpgradeException("Maximum level already achieved");
|
||||
} else {
|
||||
// TODO - Implement Perform Upgrade
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,8 @@
|
||||
package net.grosinger.nomads.exceptions;
|
||||
|
||||
public class InvalidUpgradeException extends Exception {
|
||||
|
||||
public InvalidUpgradeException(String reason){
|
||||
super(reason);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user