From 29f8d0c633b53181f4a6ee8483c1517e45a5e066 Mon Sep 17 00:00:00 2001 From: Tony Grosinger Date: Mon, 29 Aug 2011 13:46:07 -0700 Subject: [PATCH] -Created Police Class -Created Upgrade Class -Began Implementing Upgrade Signed-off-by: Tony Grosinger --- bin/net/grosinger/nomads/Drone.class | Bin 560 -> 613 bytes .../nomads/DroneListItem$Direction.class | Bin 1272 -> 1272 bytes .../nomads/DroneListItem$EnumMove.class | Bin 1480 -> 1480 bytes bin/net/grosinger/nomads/DroneListItem.class | Bin 9055 -> 9373 bytes bin/net/grosinger/nomads/Police.class | Bin 0 -> 285 bytes .../nomads/Upgrade$UpgradeType.class | Bin 0 -> 1556 bytes bin/net/grosinger/nomads/Upgrade.class | Bin 0 -> 536 bytes src/net/grosinger/nomads/Drone.java | 8 +++ src/net/grosinger/nomads/DroneListItem.java | 52 ++++++++++++------ src/net/grosinger/nomads/Police.java | 9 +++ src/net/grosinger/nomads/Upgrade.java | 14 +++++ 11 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 bin/net/grosinger/nomads/Police.class create mode 100644 bin/net/grosinger/nomads/Upgrade$UpgradeType.class create mode 100644 bin/net/grosinger/nomads/Upgrade.class create mode 100644 src/net/grosinger/nomads/Police.java create mode 100644 src/net/grosinger/nomads/Upgrade.java diff --git a/bin/net/grosinger/nomads/Drone.class b/bin/net/grosinger/nomads/Drone.class index f344d59d44533abf430ef9eb3364225a0925db39..c8918d6f8916035609fd05800f02214fb3ee39cb 100644 GIT binary patch delta 113 zcmdnM@|1<^)W2Q(7#J9g7-TkbIWuyzmlmWKC8ne@GAK+|WR&0tg>bDWdoyaYNH8*J zPZW@vJcUu1MT(I@3B*3isKCfR`5B{u5(^`P5Q8w#EG7mKFe%C)2Bf(d7#YMFBpIX~ FBmq?B71aO$ delta 82 zcmaFLvVn!`)W2Q(7#J9g7^F6GIWtbKV$@_2V`R{tC?GYNg;9`=ok4<;K?%hB#Hhf? iHd&a-K#GBhK?taYi9wh_1W0o+FfxcTh%-n!NCE)<)eW2g diff --git a/bin/net/grosinger/nomads/DroneListItem$Direction.class b/bin/net/grosinger/nomads/DroneListItem$Direction.class index 54a30415ceeac669c9ded4d13ead0247d782d966..810fd9ee3eb8ef7ac9a3f4889d73d0071126badd 100644 GIT binary patch delta 23 ecmeyt`Ga!<9}BA-g9(G|WMLK)M%l?8EE@n!-UY+} delta 23 ecmeyt`Ga!<9}BAzg9(G;WMLK)M#ae>K~q9hAPZ1Z5&u#~W`t2-h#5%x8_Tn& zT|Mir-L|uup3Sr@R;#FJ~ZM3Li{Rsue-S2-Pu}P?+&)9_%lAzE?Uy#|0-T=6=VHP z#iyECT~qXhiZ8`jN+9TUx0^A9uZ_4uNVxuvDu2(4cCU)71g&44HhG9*RWjitg2khU z7P#AcIIZ`|qLNB+1i8iQYiBd2D!C|%nfcYDZ4IRxwV*;IFT`@3Ul6k%~=XSX-tZ}0VboGt#2 zE?>Jl=<|0vySn{6-;OCxvuS>t*V*9>w)s8IR&TJO+t=b9lkfBeoIRZ$?@C`MKe^K1 z?F{m5!L?mpXH+6HWmBGtQ8XroVAIxFl8Y9IDY;bSqR)&0JR|5>6?com6BVntPoQcl zQE5C)&?d%Drc!Nle41MC@AR&1@U?r5G>IKKQ_FDHg1I}ksL~=@tevn{hL);yJ5KU_kv24Obh%2+!X;O`13}?f zp;C)}&uo7^OCwxfl~xLuGTYxBY!jX~m3+Eqp1&vJS*=og#3MRO+|#L&UwDkeWi}z{ zX}UwDZsC-hyn&#Rg4*K=xhZ#wI`doyXswv*U4)V``Af7CHRYigMY|Yl+M8%2%F$Ai z?k|}F8RanHCd8wH`+FMfs6+;)^DAZ`A2Tr#HJFN9FdMgG32L=hlRVU@WhL9R86)y& znT|q?T6J`gQJ0RsV6>J|IX$5BKyn^!)KNd9hjsKZqwP9!+4ATq9kntV(9teN&+F(C zqnC7)k&;KpbhL!gNge%^(Rm%6Oqoa@Xy()!~=ke;se-0s2ju+1z|i@w42>{M7v_oQ8qC8u{LVt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*R#W_HfE^tsc%eZmx%-;}&RXngXrO zP@u(G=N&G;rRjI!D*f9OL3@2oid{3S{D$uMV6U^JC~In!rzhXz`gUQK5-=!|=Gnpx z7L9K6P23ukU!x2zAMfF^`y^HV;?{Wd<~$^&NvMbZuYEF!tu)6`Jt{&Nhm)i z3p18IWgGf=mJ2%+hId*^(~U)%%GARFAy{`3gv!6U;DmD&_+JQ)4YNEE$J}J5#Hh!- z!+W{&!FBeI>Kh{mbzW;rX9X^N)>hGAZtqWxEi@Ui58K?;cHd#-V3!q^CG2yxZd<=n CRf3fO literal 0 HcmV?d00001 diff --git a/src/net/grosinger/nomads/Drone.java b/src/net/grosinger/nomads/Drone.java index 0cb2716..c9bd3e6 100644 --- a/src/net/grosinger/nomads/Drone.java +++ b/src/net/grosinger/nomads/Drone.java @@ -52,5 +52,13 @@ public interface Drone extends GameObject { * @return Neighbor */ public Neighbor attack(); + + /** + * Asks what the drone would like to upgrade. Will be called whenever the Move + * method returns Upgrade. + * + * @return Upgrade + */ + public Upgrade upgrade(); } diff --git a/src/net/grosinger/nomads/DroneListItem.java b/src/net/grosinger/nomads/DroneListItem.java index eb1d90a..2589329 100644 --- a/src/net/grosinger/nomads/DroneListItem.java +++ b/src/net/grosinger/nomads/DroneListItem.java @@ -11,10 +11,6 @@ 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; @@ -59,7 +55,8 @@ public class DroneListItem { /* * 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; @@ -233,7 +230,6 @@ public class DroneListItem { public boolean getInventoryIsFull() { return inventory.size() >= cargoSpace; } - /** * Sets the next DroneListItem in the Linked List @@ -244,7 +240,6 @@ public class DroneListItem { public void setNext(DroneListItem theNext) { next = theNext; } - /** * Sets the previous DroneListItem in the Linked List @@ -365,7 +360,7 @@ public class DroneListItem { return false; } case Upgrade: { - // TODO - Implement upgrade + doUpgrade(); return true; } case Attack: { @@ -396,7 +391,8 @@ public class DroneListItem { return; } - DroneListItem victimList = Nomads.UIDToListItem(victimNeighbor.getUID()); + DroneListItem victimList = Nomads + .UIDToListItem(victimNeighbor.getUID()); int victimDefence = victimList.getDefenses(); @@ -413,7 +409,7 @@ public class DroneListItem { // If number is > 70, kill if (newRand <= 35) { - // TODO - Implement wanted + wanted = true; } else if (newRand <= 70) { // Attack Failed } else if (newRand > 70) { @@ -435,7 +431,8 @@ public class DroneListItem { return; } - DroneListItem victimList = Nomads.UIDToListItem(victimNeighbor.getUID()); + DroneListItem victimList = Nomads + .UIDToListItem(victimNeighbor.getUID()); int victimDefence = victimList.getDefenses(); @@ -456,7 +453,7 @@ public class DroneListItem { Double percentToTake = .00; if (newRand <= 35) { - // TODO - Implement wanted + wanted = true; } else if (newRand <= 70) { percentToTake = .00; } else if (newRand > 70 && newRand <= 80) { @@ -471,15 +468,34 @@ 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); } } + /** + * Finds the upgrade that the drone would like to purchase. + */ + private void doUpgrade() { + Upgrade newUpgrade = current.upgrade(); + int price = newUpgrade.getPrice(); + + if (team.getBalance() >= price) { + // TODO - Implement purchasing upgrades + team.deductFromBalance(price); + } else { + // Not enough money, do nothing. + return; + } + } + /** * Move the drone in a specified direction * @@ -513,7 +529,8 @@ public class DroneListItem { } } // 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) { @@ -554,7 +571,8 @@ 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/Police.java b/src/net/grosinger/nomads/Police.java new file mode 100644 index 0000000..9394eff --- /dev/null +++ b/src/net/grosinger/nomads/Police.java @@ -0,0 +1,9 @@ +package net.grosinger.nomads; + +/** + * Enforcer of the law. Has the ability to arrest drones that are wanted. + * + */ +public class Police { + //TODO - Implement Police +} diff --git a/src/net/grosinger/nomads/Upgrade.java b/src/net/grosinger/nomads/Upgrade.java new file mode 100644 index 0000000..4ab4199 --- /dev/null +++ b/src/net/grosinger/nomads/Upgrade.java @@ -0,0 +1,14 @@ +package net.grosinger.nomads; + +public class Upgrade { + + public enum UpgradeType { + visibleDistance, lumaLocatorDistance, objectLocatorDistance, reliability, attack, defenses, speed, cargoSpace, theft + } + + private UpgradeType typeToUpgrade; + + public Upgrade(UpgradeType type){ + typeToUpgrade = type; + } +}