Archived
1
0

-Added a link to the team that owns a building

-Added method for drones to find the owner of a building
-Buildings now distinguished between public and private

Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
Tony Grosinger 2011-09-13 10:49:19 -07:00
parent c1f49275fe
commit 73cd872900
8 changed files with 27 additions and 1 deletions

Binary file not shown.

View File

@ -16,6 +16,7 @@ package net.grosinger.nomads;
public class Building implements GameObject { public class Building implements GameObject {
Structure structure; Structure structure;
String name; String name;
DroneTeam team;
int x; int x;
int y; int y;
@ -25,7 +26,7 @@ public class Building implements GameObject {
TOWNHALL, REPAIRSHOP, UPGRADESHOP, POLICESTATION, HOUSE TOWNHALL, REPAIRSHOP, UPGRADESHOP, POLICESTATION, HOUSE
} }
public Building(Structure thisBuilding, int newX, int newY) { public Building(Structure thisBuilding, int newX, int newY, DroneTeam team) {
structure = thisBuilding; structure = thisBuilding;
switch (structure) { switch (structure) {
case TOWNHALL: { case TOWNHALL: {
@ -50,6 +51,7 @@ public class Building implements GameObject {
} }
} }
this.team = team;
x = newX; x = newX;
y = newY; y = newY;
} }
@ -68,6 +70,20 @@ public class Building implements GameObject {
return structure; return structure;
} }
/**
* Retrieve the name of the team that owns the current building. If the
* building is a public building, the string will be "Public".
*
* @return <code>String</code>
*/
public String getTeam() {
if (structure == Structure.HOUSE) {
return team.getName();
} else {
return "Public";
}
}
/** /**
* Retrieve x index * Retrieve x index
* *

View File

@ -62,6 +62,16 @@ public class NeighborBuilding implements GameObject {
return building.getType(); return building.getType();
} }
/**
* Retrieve the name of the team that owns the current building. If the
* building is a public building, the string will be "Public".
*
* @return <code>String</code>
*/
public String getTeam() {
return building.getTeam();
}
@Override @Override
public void setName(String newName) { public void setName(String newName) {
name = newName; name = newName;