mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Make getNeighbors function static
This commit is contained in:
@@ -14,6 +14,7 @@ import forge.card.CardDetailUtil.DetailColors;
|
|||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.planarconquest.ConquestData;
|
import forge.planarconquest.ConquestData;
|
||||||
import forge.planarconquest.ConquestLocation;
|
import forge.planarconquest.ConquestLocation;
|
||||||
|
import forge.planarconquest.ConquestPlane;
|
||||||
import forge.planarconquest.ConquestPlane.Region;
|
import forge.planarconquest.ConquestPlane.Region;
|
||||||
import forge.planarconquest.ConquestPlaneData;
|
import forge.planarconquest.ConquestPlaneData;
|
||||||
import forge.screens.FScreen;
|
import forge.screens.FScreen;
|
||||||
@@ -81,6 +82,10 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
int rows = Region.ROWS_PER_REGION;
|
int rows = Region.ROWS_PER_REGION;
|
||||||
float colWidth = w / cols;
|
float colWidth = w / cols;
|
||||||
float rowHeight = regionHeight / rows;
|
float rowHeight = regionHeight / rows;
|
||||||
|
|
||||||
|
ConquestPlane plane = model.getCurrentPlane();
|
||||||
|
FCollectionView<Region> regions = plane.getRegions();
|
||||||
|
int regionCount = regions.size();
|
||||||
ConquestPlaneData planeData = model.getCurrentPlaneData();
|
ConquestPlaneData planeData = model.getCurrentPlaneData();
|
||||||
ConquestLocation currentLocation = model.getCurrentLocation();
|
ConquestLocation currentLocation = model.getCurrentLocation();
|
||||||
|
|
||||||
@@ -91,8 +96,6 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
float y = -getScrollTop();
|
float y = -getScrollTop();
|
||||||
float colLineStartY = 0;
|
float colLineStartY = 0;
|
||||||
float colLineEndY = h;
|
float colLineEndY = h;
|
||||||
FCollectionView<Region> regions = model.getCurrentPlane().getRegions();
|
|
||||||
int regionCount = regions.size();
|
|
||||||
|
|
||||||
//draw top portal row
|
//draw top portal row
|
||||||
if (y + rowHeight > 0) {
|
if (y + rowHeight > 0) {
|
||||||
@@ -148,7 +151,7 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
color = FOG_OF_WAR_COLOR;
|
color = FOG_OF_WAR_COLOR;
|
||||||
|
|
||||||
//if any bordering grid square has been conquered, instead show unconquered color
|
//if any bordering grid square has been conquered, instead show unconquered color
|
||||||
for (ConquestLocation loc : currentLocation.getNeighbors(i, r, c)) {
|
for (ConquestLocation loc : ConquestLocation.getNeighbors(plane, i, r, c)) {
|
||||||
if (planeData.getEventResult(loc.getRegionIndex(), loc.getRow(), loc.getCol()) > 0) {
|
if (planeData.getEventResult(loc.getRegionIndex(), loc.getRow(), loc.getCol()) > 0) {
|
||||||
color = UNCONQUERED_COLOR;
|
color = UNCONQUERED_COLOR;
|
||||||
break;
|
break;
|
||||||
@@ -184,6 +187,8 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
x0 += colWidth;
|
x0 += colWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//draw planeswalker avatar
|
||||||
|
|
||||||
g.endClip();
|
g.endClip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,41 +53,42 @@ public class ConquestLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<ConquestLocation> getNeighbors() {
|
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>();
|
List<ConquestLocation> locations = new ArrayList<ConquestLocation>();
|
||||||
|
|
||||||
//add location above
|
//add location above
|
||||||
if (row0 < Region.ROWS_PER_REGION - 1) {
|
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) {
|
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) {
|
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
|
//add location below
|
||||||
if (row0 > 0) {
|
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) {
|
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) {
|
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
|
//add locations left and right
|
||||||
if (regionIndex0 >= 0 && regionIndex0 < regionCount) { //not options in portal row
|
if (regionIndex0 >= 0 && regionIndex0 < regionCount) { //not options in portal row
|
||||||
if (col0 > 0) {
|
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) {
|
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