diff --git a/bin/net/grosinger/nomads/DroneListItem.class b/bin/net/grosinger/nomads/DroneListItem.class index f1c22c2..47e8905 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/Nomads.class b/bin/net/grosinger/nomads/Nomads.class index b788f22..a99c266 100644 Binary files a/bin/net/grosinger/nomads/Nomads.class and b/bin/net/grosinger/nomads/Nomads.class differ diff --git a/bin/net/grosinger/nomads/TownHall.class b/bin/net/grosinger/nomads/TownHall.class index d52809e..acd89ae 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/World.class b/bin/net/grosinger/nomads/World.class index ce036e1..19bfcfc 100644 Binary files a/bin/net/grosinger/nomads/World.class and b/bin/net/grosinger/nomads/World.class differ diff --git a/src/net/grosinger/nomads/DroneListItem.java b/src/net/grosinger/nomads/DroneListItem.java index 8d5f758..48a83c9 100644 --- a/src/net/grosinger/nomads/DroneListItem.java +++ b/src/net/grosinger/nomads/DroneListItem.java @@ -380,15 +380,23 @@ public class DroneListItem { // Check to see if there is a MoneyPile or Objective there GameObject objectHere = Nomads.awesomeWorld.getObjectAt(getX() + amountE, getY() + amountN); - if (inventory.size() < cargoSpace) { - if (objectHere instanceof MoneyPile) { - inventory.add(objectHere); - } else if (objectHere instanceof Objective) { - // TODO - Check to see that this drone is the owner of that - // Objective + if (objectHere != null) { + if (inventory.size() < cargoSpace) { + if (objectHere instanceof MoneyPile) { + inventory.add(objectHere); + } else if (objectHere instanceof Objective) { + String objUID = ((Objective) objectHere).getUID(); + String droneUID = current.getUID(); + + if (objUID.equals(droneUID)) { + inventory.add(objectHere); + } else { + return; + } + } + } else { + return; } - } else { - // TODO - Inventory is full, do not allow move } // Make the move diff --git a/src/net/grosinger/nomads/Nomads.java b/src/net/grosinger/nomads/Nomads.java index d51a453..9419e19 100644 --- a/src/net/grosinger/nomads/Nomads.java +++ b/src/net/grosinger/nomads/Nomads.java @@ -44,6 +44,9 @@ public class Nomads { */ public static final int MONEYPILES = 30; + public static final int MAXOBJECTIVEBOUNTY = 30; + public static final int MINOBJECTIVEBOUNTY = 10; + public static void main(String[] args) { if (DEBUGSTATUS) System.out.println("Game initialization beginning..."); diff --git a/src/net/grosinger/nomads/TownHall.java b/src/net/grosinger/nomads/TownHall.java index 23647d3..36645b3 100644 --- a/src/net/grosinger/nomads/TownHall.java +++ b/src/net/grosinger/nomads/TownHall.java @@ -16,8 +16,13 @@ public class TownHall extends Building { team.increaseBalance(value); Nomads.awesomeWorld.generateMoneyPile(); } else if (currentObject instanceof Objective) { - // TODO - Implement turning in objective + team.increaseBalance(((Objective) currentObject).getBounty()); } + inventory.remove(currentObject); } } + + public Point requestNewObjective(String UID){ + return Nomads.awesomeWorld.generateObjective(UID); + } } diff --git a/src/net/grosinger/nomads/World.java b/src/net/grosinger/nomads/World.java index 2ad9020..c88e347 100644 --- a/src/net/grosinger/nomads/World.java +++ b/src/net/grosinger/nomads/World.java @@ -114,6 +114,8 @@ public class World { */ public void setObjectAt(int x, int y, GameObject newItem) { theWorld[x][y] = newItem; + // TODO - Make sure this spot is free. + // If it is not, then move somewhere close by } /** @@ -228,6 +230,33 @@ public class World { setObjectRandom(newPile); } + /** + * Create a newObjective for the given UID. Returns a point that is randomly + * close to the actual location of the Objective + * + * @param UID + * - The UID of the Drone that is allowed to pick it up. + * @return - Point - Within 20x20 of the Objective. + */ + public Point generateObjective(String UID) { + // Min + (int)(Math.random() * ((Max - Min) + 1)) + int randX = 0 + (int) (Math.random() * ((getWorldSize() - 0) + 1)); + int randY = 0 + (int) (Math.random() * ((getWorldSize() - 0) + 1)); + + int varY = -10 + (int) (Math.random() * ((10 - -10) + 1)); + int varX = -10 + (int) (Math.random() * ((10 - -10) + 1)); + + int bounty = Nomads.MINOBJECTIVEBOUNTY + (int) (Math.random() * ((Nomads.MAXOBJECTIVEBOUNTY - Nomads.MINOBJECTIVEBOUNTY) + 1)); + + Objective newObjective = new Objective(bounty, UID); + setObjectAt(randX, randY, newObjective); + + //Create a point to return that is somewhere nearby the actual location + Point pointCloseBy = new Point(randX+varX, randY+varY); + + return pointCloseBy; + } + /** * Outputs an HTML file showing the world */