diff --git a/bin/net/grosinger/nomads/DroneListItem.class b/bin/net/grosinger/nomads/DroneListItem.class index 4480a58..f16932c 100644 Binary files a/bin/net/grosinger/nomads/DroneListItem.class and b/bin/net/grosinger/nomads/DroneListItem.class differ diff --git a/bin/net/grosinger/nomads/TownHall.class b/bin/net/grosinger/nomads/TownHall.class index 64d8585..4958976 100644 Binary files a/bin/net/grosinger/nomads/TownHall.class and b/bin/net/grosinger/nomads/TownHall.class differ diff --git a/bin/net/grosinger/nomads/exceptions/BadRequestException.class b/bin/net/grosinger/nomads/exceptions/BadRequestException.class new file mode 100644 index 0000000..3a28dd2 Binary files /dev/null and b/bin/net/grosinger/nomads/exceptions/BadRequestException.class differ diff --git a/src/net/grosinger/nomads/DroneListItem.java b/src/net/grosinger/nomads/DroneListItem.java index b93de18..f2e945b 100644 --- a/src/net/grosinger/nomads/DroneListItem.java +++ b/src/net/grosinger/nomads/DroneListItem.java @@ -244,6 +244,10 @@ public class DroneListItem { public ArrayList getCurrentObjectives() { return currentObjectives; } + + public boolean getCurrentObjectivesFull(){ + return currentObjectives.size() >= Nomads.MAXREQUESTEDOBJECTIVES; + } /** * Returns if the drone is wanted diff --git a/src/net/grosinger/nomads/TownHall.java b/src/net/grosinger/nomads/TownHall.java index 2e97d06..577538b 100644 --- a/src/net/grosinger/nomads/TownHall.java +++ b/src/net/grosinger/nomads/TownHall.java @@ -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(); diff --git a/src/net/grosinger/nomads/exceptions/BadRequestException.java b/src/net/grosinger/nomads/exceptions/BadRequestException.java new file mode 100644 index 0000000..b7ff85f --- /dev/null +++ b/src/net/grosinger/nomads/exceptions/BadRequestException.java @@ -0,0 +1,9 @@ +package net.grosinger.nomads.exceptions; + +public class BadRequestException extends Exception { + + public BadRequestException(String message) { + super(message); + } + +}