From 77c93d6c2c9eebf9b585ef7863c768b9effcc5e4 Mon Sep 17 00:00:00 2001 From: Tony Grosinger Date: Thu, 15 Sep 2011 13:41:48 -0700 Subject: [PATCH] -Added method of verifiying if a NeighborBuilding was created during the current turn. NeighborBuildings should only be used during the current turn. References to them that are used later will not function. Signed-off-by: Tony Grosinger --- .../grosinger/nomads/NeighborBuilding.class | Bin 1124 -> 1374 bytes bin/net/grosinger/nomads/TownHall.class | Bin 1875 -> 1934 bytes .../grosinger/nomads/NeighborBuilding.java | 14 +++++++++- src/net/grosinger/nomads/TownHall.java | 24 ++++++++++++++++-- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/bin/net/grosinger/nomads/NeighborBuilding.class b/bin/net/grosinger/nomads/NeighborBuilding.class index 4699e6c83ee5f2ab7705226fb4881bdc89ffae44..0f34ca2105e53749d0b77fc2eca8785c09c04e73 100644 GIT binary patch literal 1374 zcmah{+fEZv6kVsCc1jtf0tHLC2#B=9rHXA38ue}3j%Bc&n&}kf8~h1B zfCn{J6CeBlzsVTanHerAlbFfOKIhC{Yp=cb`Th6jF9569P!SQBw@tTDcUo=BuA5H5 zZZ(ZsyHGT(`az}TJnmSH8vm$J1X72_kx^(EcD=AyIW()TinzdZD8X~1Y5GY5ip`C{ z(C#^Y-*w2kA<*x39DCa_4cDv*h#kHk_#O)+DnV_Q*bS|5DvmVqP0P02ErIpi&d%jJ z|H0?W6uI51nMp)3tYHu%0?}N)+y{YC4gE;U)in*8zZ%z|A|cNvGz{QMAEt0!#k4>+ zRB6$3Rl^LDtR!2O*f|Y-@?db+vdvy=Y&e$O2ZxG#V6_Dn!kg)x z7)?>@rd#x^AIaq}n?fZ_cFjtGFdF8QRjR`5KmyC#-#1E1kPs zN*b)%=KDa+k?B}(j{WOVHX2sVayf7s{+bt}+HoAyc1tu#U|`=hs&8Ky?*b2!`>l>s zHJ@41rF3u4EAoQTWODJ1@rlSe@wP{#(_Z8(y~s&=k<(*TnLmgWzgM~Y$ov@NjQ#^d zdbW$SKGDUPzT8Dd&nR7F^{<%hV)lziaf9C}QUDn!7-y+0NhdIjNuKa#U>fuMd)Ft$ zO)PLndU>%}Qm&+&h_{l0quxqNQ}{oJd?2jADDz|bH)K9@5rHfo_YUX0BATBN6cNy| z$P?MsMR5A02fP#tUJ3<|^@7(z!Mqni_%;EL?-0e2BR{0G=^_MiX& literal 1124 zcmah{%Wl&^6g`tTaT-ip+9WiOQVNtN4y~oCVgt&8B2c6#ELugdbP_9dmDrNw@YwM| zEI=Y4vET#vD8!j@+9Jn-#ms&9o_o(d<6pmj`~+|WOGipz&vQa+6!=ru8##gH`4f9M zwYrWwI`8|zvza>{@{0~lVEw{=Yg=R68(FXV7tSEmkrmiUZ1B>aI8l*+<}nc1=v?DZ z!+>3%2#EJQZJrMTx&C4rn|2brUeX~j`_%Q^uqE)g-fk~<{tv#chJjUV z3Z(0e-UDT~4eVi; zu<7NjVtsj(6iN4-cM+TXsXq$_&I?zrT8tAvly8e&>XYWlKtoCj#vd&u#Z;D3Dogoj zv#eXi8t-*RA6b{7t(f0&%dE~(Fl%#^%!4_$%(6B|<%`1BWDT)EnKLTvU1gUVHnGjj z9p1ok)QQm!BUvvQ2<1r*DdkCaY2`^i8o%FF{3RQUk*v>{U$OO>PKqNU%D_D}#E1$O zLj<$;nTdl7pJL!#o_<} diff --git a/bin/net/grosinger/nomads/TownHall.class b/bin/net/grosinger/nomads/TownHall.class index 3b69d5ec7b7d06e54ecdbbdf0190764903f1c870..03558cf7313f760866be3b216ba4eab5eb8b0a75 100644 GIT binary patch delta 227 zcmXAiyJ`Yq6okKjmyM|FZoCB(qrr%TC`OdDR$?OoLCu;=rHR4@D_I0z!e%SGJc3$S zSOij}vCaF42V`K*HwT9Kw-)yK{;>N2YP<)~6dC_lCD(@Chn)}%|krmnDqT8!!sfTvHU+{bDu)z5|b<9q`4N|lA%Oa7H+7Mqd|%mdH?%t zGH}pD5G`)$ED3KYm$p2w)JmQ@A#qDCJP@FQO_i{ui&IHvB9f%e3o#UJVI5@)z6xr* F9RV%kBOd?& delta 168 zcmXAhISK+n6hvRQ^tkotxXg&SfP#SxCSs_Ofnex<2+cf)Nnb=KFfb4%HT4c2L;N5G zk18nMrTi`hukYgtj5%b{ijGTFcpLPLH(_nrxRW^>OCH~SOfn3}P{C5ACTUZrPe@E8 yf(A31%n4Z1a;bM*Owkg^C5+-btE+TPLFl1`U5di!{}HP%OWth7uOvHJn*9%j`W4>* 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; + } } }