diff --git a/bin/net/grosinger/nomads/DroneListItem$Direction.class b/bin/net/grosinger/nomads/DroneListItem$Direction.class index 810fd9e..54a3041 100644 Binary files a/bin/net/grosinger/nomads/DroneListItem$Direction.class and b/bin/net/grosinger/nomads/DroneListItem$Direction.class differ diff --git a/bin/net/grosinger/nomads/DroneListItem$EnumMove.class b/bin/net/grosinger/nomads/DroneListItem$EnumMove.class index 25ad3e6..48dff9c 100644 Binary files a/bin/net/grosinger/nomads/DroneListItem$EnumMove.class and b/bin/net/grosinger/nomads/DroneListItem$EnumMove.class differ diff --git a/bin/net/grosinger/nomads/DroneListItem.class b/bin/net/grosinger/nomads/DroneListItem.class index 3ad8935..d82813c 100644 Binary files a/bin/net/grosinger/nomads/DroneListItem.class and b/bin/net/grosinger/nomads/DroneListItem.class differ diff --git a/src/net/grosinger/nomads/DroneListItem.java b/src/net/grosinger/nomads/DroneListItem.java index 376bca2..eb1d90a 100644 --- a/src/net/grosinger/nomads/DroneListItem.java +++ b/src/net/grosinger/nomads/DroneListItem.java @@ -11,6 +11,10 @@ import java.util.ArrayList; * * Previous --> Towards the first item Next --> Towards the last item */ +/** + * @author tgrosinger + * + */ public class DroneListItem { private DroneListItem next; private DroneListItem previous; @@ -49,6 +53,7 @@ public class DroneListItem { private int x; private int y; private int waiting; // Is the drone building another drone or house? + private boolean wanted; // Is the drone wanted by the police? private ArrayList inventory; /* @@ -202,6 +207,15 @@ public class DroneListItem { return y; } + /** + * Returns if the drone is wanted + * + * @return boolean + */ + public boolean getWanted() { + return wanted; + } + /** * Retrieve reference to the team this drone belongs to * @@ -211,9 +225,15 @@ public class DroneListItem { return team; } + /** + * Find if the inventory is full + * + * @return Boolean + */ public boolean getInventoryIsFull() { return inventory.size() >= cargoSpace; } + /** * Sets the next DroneListItem in the Linked List @@ -224,6 +244,7 @@ public class DroneListItem { public void setNext(DroneListItem theNext) { next = theNext; } + /** * Sets the previous DroneListItem in the Linked List @@ -294,6 +315,13 @@ public class DroneListItem { // Actions + /** + * Removes this drone from the team + */ + public void die() { + team.removeDrone(this); + } + /** * Will ask the Drone what direction it would like to move * @@ -381,11 +409,19 @@ public class DroneListItem { newRand += rand; // If number is <= 35, drone becomes wanted - // If number is <= 70, steal fails - // If number is > 70, steal - // Depending on how much higher than 70, more items will be stolen + // If number is <= 70, attack fails + // If number is > 70, kill - // TODO - Continue implementing attack + if (newRand <= 35) { + // TODO - Implement wanted + } else if (newRand <= 70) { + // Attack Failed + } else if (newRand > 70) { + // Drone Killed + killOtherDrone(victimList); + } else { + // Not sure what happened here + } } /** @@ -444,6 +480,12 @@ public class DroneListItem { } } + /** + * Move the drone in a specified direction + * + * @param direction + * Direction to move + */ private void moveDrone(Direction direction) { if (waiting != 0) { waiting--; @@ -501,4 +543,22 @@ public class DroneListItem { if (amountE != 0) setX(getX() + amountE); } + + /** + * Kills another drone. Will take a random assortment of the items in their + * inventory. + * + * @param victim + * - DroneListItem to be killed + */ + 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)); + inventory.add(victim.inventory.get(randIndex)); + victim.inventory.remove(randIndex); + } + + victim.die(); + } }