mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Make getNeighbors function static
This commit is contained in:
@@ -53,41 +53,42 @@ public class ConquestLocation {
|
||||
}
|
||||
|
||||
public List<ConquestLocation> getNeighbors() {
|
||||
return getNeighbors(regionIndex, row, col);
|
||||
return getNeighbors(plane, regionIndex, row, col);
|
||||
}
|
||||
public List<ConquestLocation> getNeighbors(int regionIndex0, int row0, int col0) {
|
||||
int regionCount = plane.getRegions().size();
|
||||
|
||||
public static List<ConquestLocation> getNeighbors(ConquestPlane plane0, int regionIndex0, int row0, int col0) {
|
||||
int regionCount = plane0.getRegions().size();
|
||||
List<ConquestLocation> locations = new ArrayList<ConquestLocation>();
|
||||
|
||||
//add location above
|
||||
if (row0 < Region.ROWS_PER_REGION - 1) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0, row0 + 1, col0));
|
||||
locations.add(new ConquestLocation(plane0, regionIndex0, row0 + 1, col0));
|
||||
}
|
||||
else if (regionIndex0 < regionCount - 1) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0 + 1, 0, col0));
|
||||
locations.add(new ConquestLocation(plane0, regionIndex0 + 1, 0, col0));
|
||||
}
|
||||
else if (regionIndex0 == regionCount - 1 && col0 == Region.PORTAL_COL) {
|
||||
locations.add(new ConquestLocation(plane, regionCount, 0, col0));
|
||||
locations.add(new ConquestLocation(plane0, regionCount, 0, col0));
|
||||
}
|
||||
|
||||
//add location below
|
||||
if (row0 > 0) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0, row0 - 1, col0));
|
||||
locations.add(new ConquestLocation(plane0, regionIndex0, row0 - 1, col0));
|
||||
}
|
||||
else if (regionIndex0 > 0) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0 - 1, Region.ROWS_PER_REGION - 1, col0));
|
||||
locations.add(new ConquestLocation(plane0, regionIndex0 - 1, Region.ROWS_PER_REGION - 1, col0));
|
||||
}
|
||||
else if (regionIndex0 == 0 && col0 == Region.PORTAL_COL) {
|
||||
locations.add(new ConquestLocation(plane, -1, 0, col0));
|
||||
locations.add(new ConquestLocation(plane0, -1, 0, col0));
|
||||
}
|
||||
|
||||
//add locations left and right
|
||||
if (regionIndex0 >= 0 && regionIndex0 < regionCount) { //not options in portal row
|
||||
if (col0 > 0) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0, row0, col0 - 1));
|
||||
locations.add(new ConquestLocation(plane0, regionIndex0, row0, col0 - 1));
|
||||
}
|
||||
if (col0 < Region.COLS_PER_REGION - 1) {
|
||||
locations.add(new ConquestLocation(plane, regionIndex0, row0, col0 + 1));
|
||||
locations.add(new ConquestLocation(plane0, regionIndex0, row0, col0 + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user