diff --git a/bin/net/grosinger/nomads/DroneListItem.class b/bin/net/grosinger/nomads/DroneListItem.class index 4f08f80..bfe90a9 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/NeighborBuilding.class b/bin/net/grosinger/nomads/NeighborBuilding.class index 3a023a8..f4f69c3 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 5d7e0c5..01f697c 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 958c25a..9ea7016 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 db9ba5b..fc6a363 100644 --- a/src/net/grosinger/nomads/DroneListItem.java +++ b/src/net/grosinger/nomads/DroneListItem.java @@ -52,12 +52,15 @@ public class DroneListItem { private int waiting; // Is the drone building another drone or house? private boolean wanted; // Is the drone wanted by the police? private ArrayList inventory; + private ArrayList currentObjectives; + + // TODO - Implement max number of objectives /* * Default constructor, includes all references */ - public DroneListItem(DroneListItem theNext, DroneListItem thePrevious, - Drone theCurrent, DroneTeam theTeam) { + public DroneListItem(DroneListItem theNext, DroneListItem thePrevious, Drone theCurrent, + DroneTeam theTeam) { next = theNext; previous = thePrevious; current = theCurrent; @@ -404,8 +407,7 @@ public class DroneListItem { return; } - DroneListItem victimList = Nomads - .UIDToListItem(victimNeighbor.getUID()); + DroneListItem victimList = Nomads.UIDToListItem(victimNeighbor.getUID()); int victimDefence = victimList.getDefenses(); @@ -444,8 +446,7 @@ public class DroneListItem { return; } - DroneListItem victimList = Nomads - .UIDToListItem(victimNeighbor.getUID()); + DroneListItem victimList = Nomads.UIDToListItem(victimNeighbor.getUID()); int victimDefence = victimList.getDefenses(); @@ -481,13 +482,10 @@ public class DroneListItem { // Not sure what happened here } - int itemsToTake = (int) Math.ceil(itemsInVictimInventory - * percentToTake); - while (itemsToTake < 0 && !getInventoryIsFull() - && victimList.inventory.size() > 0) { + int itemsToTake = (int) Math.ceil(itemsInVictimInventory * percentToTake); + while (itemsToTake < 0 && !getInventoryIsFull() && victimList.inventory.size() > 0) { // Min + (int)(Math.random() * ((Max - Min) + 1)) - int randIndex = 0 + (int) (Math.random() * (((victimList.inventory - .size() - 1) - 0) + 1)); + int randIndex = 0 + (int) (Math.random() * (((victimList.inventory.size() - 1) - 0) + 1)); inventory.add(victimList.inventory.get(randIndex)); victimList.inventory.remove(randIndex); } @@ -526,16 +524,14 @@ public class DroneListItem { } } - if (getX() + amountE > Nomads.awesomeWorld.getWorldSize() - 1 - || getX() + amountE < 0 + if (getX() + amountE > Nomads.awesomeWorld.getWorldSize() - 1 || getX() + amountE < 0 || getY() + amountN > Nomads.awesomeWorld.getWorldSize() - 1 || getY() + amountN < 0) { return; } // Check to see if there is a MoneyPile or Objective there - GameObject objectHere = Nomads.awesomeWorld.getObjectAt(getX() - + amountE, getY() + amountN); + GameObject objectHere = Nomads.awesomeWorld.getObjectAt(getX() + amountE, getY() + amountN); if (objectHere != null) { if (inventory.size() < cargoSpace) { @@ -576,8 +572,7 @@ public class DroneListItem { private void killOtherDrone(DroneListItem victim) { while (inventory.size() < cargoSpace && !victim.inventory.isEmpty()) { // Take items from their inventory - int randIndex = 0 + (int) (Math.random() * (((victim.inventory - .size() - 1) - 0) + 1)); + int randIndex = 0 + (int) (Math.random() * (((victim.inventory.size() - 1) - 0) + 1)); inventory.add(victim.inventory.get(randIndex)); victim.inventory.remove(randIndex); } diff --git a/src/net/grosinger/nomads/NeighborBuilding.java b/src/net/grosinger/nomads/NeighborBuilding.java index 23d5d69..8b40dbe 100644 --- a/src/net/grosinger/nomads/NeighborBuilding.java +++ b/src/net/grosinger/nomads/NeighborBuilding.java @@ -11,7 +11,7 @@ public class NeighborBuilding implements GameObject { private int x; private int y; private Building building; - private DroneListItem drone; + protected DroneListItem drone; /** * Class Constructor diff --git a/src/net/grosinger/nomads/TownHall.java b/src/net/grosinger/nomads/TownHall.java index 9dfb6eb..7901906 100644 --- a/src/net/grosinger/nomads/TownHall.java +++ b/src/net/grosinger/nomads/TownHall.java @@ -9,8 +9,7 @@ public class TownHall extends NeighborBuilding { // TODO - Rewrite class to make more accessible to Drones - public TownHall(int x, int y, String name, Building building, - DroneListItem drone) { + public TownHall(int x, int y, String name, Building building, DroneListItem drone) { super(x, y, name, building, drone); } @@ -21,17 +20,19 @@ public class TownHall extends NeighborBuilding { * @param inventory * @param team */ - public void cashInventory(ArrayList inventory, DroneTeam team) { + public void cashInventory() { if (verifyObjectValidity()) { + Inventory inventory = drone.getInventory(); + DroneTeam team = drone.getTeam(); + while (!inventory.isEmpty()) { - GameObject currentObject = inventory.get(0); + GameObject currentObject = inventory.getItem(0); if (currentObject instanceof MoneyPile) { int value = ((MoneyPile) currentObject).getValue(); team.increaseBalance(value); Nomads.awesomeWorld.generateMoneyPile(); } else if (currentObject instanceof Objective) { - team.increaseBalance(((Objective) currentObject) - .getBounty()); + team.increaseBalance(((Objective) currentObject).getBounty()); } inventory.remove(currentObject); } @@ -43,14 +44,12 @@ 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) { + public Point requestNewObjective() { if (verifyObjectValidity()) { - return Nomads.awesomeWorld.generateObjective(UID); + return Nomads.awesomeWorld.generateObjective(drone); } else { // Object not valid, do nothing return null; diff --git a/src/net/grosinger/nomads/World.java b/src/net/grosinger/nomads/World.java index 5981fbf..b59dfce 100644 --- a/src/net/grosinger/nomads/World.java +++ b/src/net/grosinger/nomads/World.java @@ -5,11 +5,12 @@ import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.math.BigInteger; +import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; - /** * Main class where information about the world is stored * @@ -233,9 +234,11 @@ public class World { GameObject objectHere = theWorld[x + i][y + j]; if (objectHere != null) { String name = objectHere.getName(); - if (name.equalsIgnoreCase("TownHall") || name.equalsIgnoreCase("PoliceStation")) { + if (name.equalsIgnoreCase("TownHall") + || name.equalsIgnoreCase("PoliceStation")) { return true; - } else if ((name.equalsIgnoreCase("RepairShop") || name.equalsIgnoreCase("UpgradeShop")) && i <= 2 && j <= 2) { + } else if ((name.equalsIgnoreCase("RepairShop") || name + .equalsIgnoreCase("UpgradeShop")) && i <= 2 && j <= 2) { return true; } } @@ -297,7 +300,7 @@ public class World { * - The UID of the Drone that is allowed to pick it up. * @return - Point - Within 20x20 of the Objective. */ - public Point generateObjective(String UID) { + public Point generateObjective(DroneListItem drone) { // 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)); @@ -305,9 +308,10 @@ public class World { 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)); + int bounty = Nomads.MINOBJECTIVEBOUNTY + + (int) (Math.random() * ((Nomads.MAXOBJECTIVEBOUNTY - Nomads.MINOBJECTIVEBOUNTY) + 1)); - Objective newObjective = new Objective(bounty, UID); + Objective newObjective = new Objective(bounty, drone.getCurrent().getUID()); setObjectAt(randX, randY, newObjective); // Create a point to return that is somewhere nearby the actual location