Archived
1
0

-Created BadRequestException

-Finished implementation of max Objectives

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-09-16 11:38:44 -07:00
parent 7b0b2b666d
commit e323a0064d
6 changed files with 20 additions and 1 deletions

View File

@ -245,6 +245,10 @@ public class DroneListItem {
return currentObjectives;
}
public boolean getCurrentObjectivesFull(){
return currentObjectives.size() >= Nomads.MAXREQUESTEDOBJECTIVES;
}
/**
* Returns if the drone is wanted
*

View File

@ -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();

View File

@ -0,0 +1,9 @@
package net.grosinger.nomads.exceptions;
public class BadRequestException extends Exception {
public BadRequestException(String message) {
super(message);
}
}