-Fixed testing of valid moves
Signed-off-by: Tony Grosinger <tony@grosinger.net>
This commit is contained in:
parent
92387b4759
commit
564c97c8b9
Binary file not shown.
Binary file not shown.
@ -497,8 +497,8 @@ public class DroneListItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds the upgrade that the drone would like to purchase.
|
* Finds the upgrade that the drone would like to purchase. Determines if
|
||||||
* Determines if upgrade is possible and performs action accordingly
|
* upgrade is possible and performs action accordingly
|
||||||
*/
|
*/
|
||||||
private void doUpgrade() {
|
private void doUpgrade() {
|
||||||
Upgrade newUpgrade = current.upgrade();
|
Upgrade newUpgrade = current.upgrade();
|
||||||
@ -575,11 +575,11 @@ public class DroneListItem {
|
|||||||
int amountE = 0;
|
int amountE = 0;
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case N: {
|
case N: {
|
||||||
amountN = 1;
|
amountN = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case S: {
|
case S: {
|
||||||
amountN = -1;
|
amountN = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case E: {
|
case E: {
|
||||||
@ -591,6 +591,8 @@ public class DroneListItem {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO - validate that the move is a valid location
|
||||||
|
|
||||||
// Check to see if there is a MoneyPile or Objective there
|
// Check to see if there is a MoneyPile or Objective there
|
||||||
GameObject objectHere = Nomads.awesomeWorld.getObjectAt(getX()
|
GameObject objectHere = Nomads.awesomeWorld.getObjectAt(getX()
|
||||||
+ amountE, getY() + amountN);
|
+ amountE, getY() + amountN);
|
||||||
|
@ -59,7 +59,7 @@ public class DroneTools {
|
|||||||
* @return <code>Boolean</code> - can move
|
* @return <code>Boolean</code> - can move
|
||||||
*/
|
*/
|
||||||
public boolean canMoveNorth() {
|
public boolean canMoveNorth() {
|
||||||
return canMoveHelper(getX(), getY() + 1);
|
return canMoveHelper(getX(), getY() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +68,7 @@ public class DroneTools {
|
|||||||
* @return <code>Boolean</code> - can move
|
* @return <code>Boolean</code> - can move
|
||||||
*/
|
*/
|
||||||
public boolean canMoveSouth() {
|
public boolean canMoveSouth() {
|
||||||
return canMoveHelper(getX(), getY() - 1);
|
return canMoveHelper(getX(), getY() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,14 +100,14 @@ public class DroneTools {
|
|||||||
*/
|
*/
|
||||||
private boolean canMoveHelper(int x, int y) {
|
private boolean canMoveHelper(int x, int y) {
|
||||||
// Account for being able to move onto MoneyPiles and Objectives
|
// Account for being able to move onto MoneyPiles and Objectives
|
||||||
|
// Check to make sure spot is on the map
|
||||||
if (getY() < worldSize - 1) {
|
if (x >= 0 && y >= 0 && x <= worldSize - 1 && y <= worldSize - 1) {
|
||||||
GameObject objectHere = worldReference.getWorld()[getX()][getY() + 1];
|
GameObject objectHere = worldReference.getWorld()[x][y];
|
||||||
if (objectHere == null || objectHere instanceof MoneyPile || objectHere instanceof Objective)
|
if (objectHere == null || objectHere instanceof MoneyPile
|
||||||
|
|| objectHere instanceof Objective)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -133,14 +133,19 @@ public class DroneTools {
|
|||||||
int maxDistance = listItem.getVisibleDistance();
|
int maxDistance = listItem.getVisibleDistance();
|
||||||
for (int i = maxDistance * -1; i <= maxDistance; i++) {
|
for (int i = maxDistance * -1; i <= maxDistance; i++) {
|
||||||
for (int j = maxDistance * -1; j <= maxDistance; j++) {
|
for (int j = maxDistance * -1; j <= maxDistance; j++) {
|
||||||
if (getX() + i >= worldSize - 1 || getX() + i < 0 || getY() + j >= worldSize - 1 || getY() + j < 0) {
|
if (getX() + i >= worldSize - 1 || getX() + i < 0
|
||||||
|
|| getY() + j >= worldSize - 1 || getY() + j < 0) {
|
||||||
|
|
||||||
} else if (i != 0 && j != 0) {
|
} else if (i != 0 && j != 0) {
|
||||||
GameObject objectHere = worldReference.getObjectAt(getX() + i, getY() + j);
|
GameObject objectHere = worldReference.getObjectAt(getX()
|
||||||
|
+ i, getY() + j);
|
||||||
if (objectHere instanceof Drone) {
|
if (objectHere instanceof Drone) {
|
||||||
Drone droneHere = (Drone) objectHere;
|
Drone droneHere = (Drone) objectHere;
|
||||||
DroneListItem listItemHere = Nomads.droneToListItem(droneHere);
|
DroneListItem listItemHere = Nomads
|
||||||
Neighbor aWildNeighbor = new Neighbor(listItemHere.getX(), listItemHere.getY(), droneHere.getName(), droneHere.getUID());
|
.droneToListItem(droneHere);
|
||||||
|
Neighbor aWildNeighbor = new Neighbor(
|
||||||
|
listItemHere.getX(), listItemHere.getY(),
|
||||||
|
droneHere.getName(), droneHere.getUID());
|
||||||
neighbors.add(aWildNeighbor);
|
neighbors.add(aWildNeighbor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +167,8 @@ public class DroneTools {
|
|||||||
Point intendedPoint = new Point(getX(), getY());
|
Point intendedPoint = new Point(getX(), getY());
|
||||||
findEmptyPoint(intendedPoint);
|
findEmptyPoint(intendedPoint);
|
||||||
|
|
||||||
House newHouse = new House(Structure.HOUSE, intendedPoint.getX(), intendedPoint.getY(), referredDrone.getName());
|
House newHouse = new House(Structure.HOUSE, intendedPoint.getX(),
|
||||||
|
intendedPoint.getY(), referredDrone.getName());
|
||||||
worldReference.placeNewBuilding(newHouse);
|
worldReference.placeNewBuilding(newHouse);
|
||||||
currentTeam.deductFromBalance(Nomads.HOUSEPRICE);
|
currentTeam.deductFromBalance(Nomads.HOUSEPRICE);
|
||||||
listItem.setWaiting(Nomads.CREATIONTIME);
|
listItem.setWaiting(Nomads.CREATIONTIME);
|
||||||
@ -192,7 +198,8 @@ public class DroneTools {
|
|||||||
*/
|
*/
|
||||||
private Point findEmptyPoint(Point currentPoint) {
|
private Point findEmptyPoint(Point currentPoint) {
|
||||||
// Current point is where the drone is
|
// Current point is where the drone is
|
||||||
boolean validSpace = worldReference.getObjectAt(currentPoint.getX(), currentPoint.getY()) == null;
|
boolean validSpace = worldReference.getObjectAt(currentPoint.getX(),
|
||||||
|
currentPoint.getY()) == null;
|
||||||
Point tryThis = new Point(currentPoint.getX(), currentPoint.getY());
|
Point tryThis = new Point(currentPoint.getX(), currentPoint.getY());
|
||||||
int outX = 1;
|
int outX = 1;
|
||||||
int outY = 0;
|
int outY = 0;
|
||||||
|
Reference in New Issue
Block a user