-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.
@ -245,6 +245,10 @@ public class DroneListItem {
|
||||
return currentObjectives;
|
||||
}
|
||||
|
||||
public boolean getCurrentObjectivesFull(){
|
||||
return currentObjectives.size() >= Nomads.MAXREQUESTEDOBJECTIVES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the drone is wanted
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.grosinger.nomads;
|
||||
|
||||
import net.grosinger.nomads.exceptions.BadRequestException;
|
||||
import net.grosinger.nomads.exceptions.ObjectReferenceOutdatedException;
|
||||
|
||||
/**
|
||||
@ -44,9 +45,14 @@ public class TownHall extends NeighborBuilding {
|
||||
* created in a previous turn.
|
||||
*
|
||||
* @throws ObjectReferenceOutdatedException
|
||||
* @throws BadRequestException
|
||||
*/
|
||||
public Point requestNewObjective() throws ObjectReferenceOutdatedException {
|
||||
public Point requestNewObjective() throws ObjectReferenceOutdatedException, BadRequestException {
|
||||
if (verifyObjectValidity()) {
|
||||
if (drone.getCurrentObjectivesFull()) {
|
||||
throw new BadRequestException(
|
||||
"Maximum number of requested objectives already achieved");
|
||||
}
|
||||
return Nomads.awesomeWorld.generateObjective(drone);
|
||||
} else {
|
||||
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