-Created BadRequestException
-Finished implementation of max Objectives Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
7b0b2b666d
commit
e323a0064d
Binary file not shown.
Binary file not shown.
BIN
bin/net/grosinger/nomads/exceptions/BadRequestException.class
Normal file
BIN
bin/net/grosinger/nomads/exceptions/BadRequestException.class
Normal file
Binary file not shown.
@ -244,6 +244,10 @@ public class DroneListItem {
|
|||||||
public ArrayList<Objective> getCurrentObjectives() {
|
public ArrayList<Objective> getCurrentObjectives() {
|
||||||
return currentObjectives;
|
return currentObjectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCurrentObjectivesFull(){
|
||||||
|
return currentObjectives.size() >= Nomads.MAXREQUESTEDOBJECTIVES;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the drone is wanted
|
* Returns if the drone is wanted
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.grosinger.nomads;
|
package net.grosinger.nomads;
|
||||||
|
|
||||||
|
import net.grosinger.nomads.exceptions.BadRequestException;
|
||||||
import net.grosinger.nomads.exceptions.ObjectReferenceOutdatedException;
|
import net.grosinger.nomads.exceptions.ObjectReferenceOutdatedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,9 +45,14 @@ public class TownHall extends NeighborBuilding {
|
|||||||
* created in a previous turn.
|
* created in a previous turn.
|
||||||
*
|
*
|
||||||
* @throws ObjectReferenceOutdatedException
|
* @throws ObjectReferenceOutdatedException
|
||||||
|
* @throws BadRequestException
|
||||||
*/
|
*/
|
||||||
public Point requestNewObjective() throws ObjectReferenceOutdatedException {
|
public Point requestNewObjective() throws ObjectReferenceOutdatedException, BadRequestException {
|
||||||
if (verifyObjectValidity()) {
|
if (verifyObjectValidity()) {
|
||||||
|
if (drone.getCurrentObjectivesFull()) {
|
||||||
|
throw new BadRequestException(
|
||||||
|
"Maximum number of requested objectives already achieved");
|
||||||
|
}
|
||||||
return Nomads.awesomeWorld.generateObjective(drone);
|
return Nomads.awesomeWorld.generateObjective(drone);
|
||||||
} else {
|
} else {
|
||||||
throw new ObjectReferenceOutdatedException();
|
throw new ObjectReferenceOutdatedException();
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package net.grosinger.nomads.exceptions;
|
||||||
|
|
||||||
|
public class BadRequestException extends Exception {
|
||||||
|
|
||||||
|
public BadRequestException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user