diff --git a/bin/net/grosinger/nomads/NeighborBuilding.class b/bin/net/grosinger/nomads/NeighborBuilding.class
index 4699e6c..0f34ca2 100644
Binary files a/bin/net/grosinger/nomads/NeighborBuilding.class and b/bin/net/grosinger/nomads/NeighborBuilding.class differ
diff --git a/bin/net/grosinger/nomads/TownHall.class b/bin/net/grosinger/nomads/TownHall.class
index 3b69d5e..03558cf 100644
Binary files a/bin/net/grosinger/nomads/TownHall.class and b/bin/net/grosinger/nomads/TownHall.class differ
diff --git a/src/net/grosinger/nomads/NeighborBuilding.java b/src/net/grosinger/nomads/NeighborBuilding.java
index 03a81e3..6ad86c1 100644
--- a/src/net/grosinger/nomads/NeighborBuilding.java
+++ b/src/net/grosinger/nomads/NeighborBuilding.java
@@ -1,6 +1,5 @@
package net.grosinger.nomads;
-
/**
* An array of NeigborBuildings will be given to a drone that is searching for
* the buildings it is near. This is typically done from the town center.
@@ -8,6 +7,7 @@ package net.grosinger.nomads;
public class NeighborBuilding implements GameObject {
private String name;
+ private int turnCreated;
private int x;
private int y;
private Building building;
@@ -27,6 +27,7 @@ public class NeighborBuilding implements GameObject {
this.y = y;
this.name = name;
this.building = building;
+ turnCreated = Nomads.turn;
}
@Override
@@ -67,4 +68,15 @@ public class NeighborBuilding implements GameObject {
name = newName;
}
+ /**
+ * Checks to make sure the object was created this turn. Otherwise drones
+ * could save a reference to the object and use it from anywhere on the map.
+ *
+ * @return boolean
+ */
+ protected boolean verifyObjectValidity() {
+ int currentTurn = Nomads.turn;
+ return currentTurn == turnCreated;
+ }
+
}
diff --git a/src/net/grosinger/nomads/TownHall.java b/src/net/grosinger/nomads/TownHall.java
index 237b16a..2eecd9c 100644
--- a/src/net/grosinger/nomads/TownHall.java
+++ b/src/net/grosinger/nomads/TownHall.java
@@ -2,16 +2,24 @@ package net.grosinger.nomads;
import java.util.ArrayList;
-
/**
* A representation of a TownHall. Allows Drones to interact with this building.
*/
public class TownHall extends NeighborBuilding {
+ // TODO - Rewrite class to make more accessible to Drones
+
public TownHall(int x, int y, String name, Building building) {
super(x, y, name, building);
}
+ /**
+ * Will sell all items in inventory that are able to be sold to the Town
+ * Hall.
+ *
+ * @param inventory
+ * @param team
+ */
public void cashInventory(ArrayList inventory, DroneTeam team) {
while (!inventory.isEmpty()) {
GameObject currentObject = inventory.get(0);
@@ -26,7 +34,19 @@ public class TownHall extends NeighborBuilding {
}
}
+ /**
+ * Will generate a new objective for the drone that requests it.
+ *
+ * @param UID
+ * Depreciated and going away soon.
+ * @return Point
Will return null if the NeighborBuilding was
+ * created in a previous turn.
+ */
public Point requestNewObjective(String UID) {
- return Nomads.awesomeWorld.generateObjective(UID);
+ if (verifyObjectValidity()) {
+ return Nomads.awesomeWorld.generateObjective(UID);
+ } else {
+ return null;
+ }
}
}