Add fog of war support and planar portal image

This commit is contained in:
drdev
2015-11-29 18:12:18 +00:00
parent 3541c36cf1
commit 9f445b0a38
8 changed files with 82 additions and 74 deletions

View File

@@ -243,13 +243,7 @@ public enum FSkinProp {
IMG_TROPHY_SHELF (new int[] {0, 223, 798, 257}, PropType.TROPHY),
//planar conquest images
IMG_HEXAGON_TILE (new int[] {354, 0, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_COLORLESS_TILE (new int[] {0, 354, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_WHITE_TILE (new int[] {0, 0, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_BLUE_TILE (new int[] {89, 177, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_BLACK_TILE (new int[] {177, 0, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_RED_TILE (new int[] {266, 177, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_GREEN_TILE (new int[] {177, 354, 151, 173}, PropType.PLANAR_CONQUEST),
IMG_PLANAR_PORTAL (new int[] {0, 0, 293, 75}, PropType.PLANAR_CONQUEST),
//button images
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),

View File

@@ -1,36 +0,0 @@
package forge.planarconquest;
public class ConquestEventRecord {
private int wins, losses;
private int winStreakBest = 0;
private int winStreakCurrent = 0;
public void addWin() {
wins++;
winStreakCurrent++;
if (winStreakCurrent > winStreakBest) {
winStreakBest = winStreakCurrent;
}
}
public void addLoss(ConquestCommander opponent) {
losses++;
winStreakCurrent = 0;
}
public int getWins() {
return wins;
}
public int getLosses() {
return losses;
}
public int getWinStreakBest() {
return winStreakBest;
}
public int getWinStreakCurrent() {
return winStreakCurrent;
}
}

View File

@@ -14,6 +14,13 @@ public class ConquestLocation {
public ConquestLocation() {
}
private ConquestLocation(ConquestPlane plane0, int regionIndex0, int row0, int col0) {
plane = plane0;
regionIndex = regionIndex0;
row = row0;
col = col0;
}
public ConquestPlane getPlane() {
return plane;
}
@@ -52,13 +59,43 @@ public class ConquestLocation {
return getNeighbors(regionIndex, row, col);
}
public List<ConquestLocation> getNeighbors(int regionIndex0, int row0, int col0) {
int regionCount = plane.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));
}
else if (regionIndex0 < regionCount - 1) {
locations.add(new ConquestLocation(plane, regionIndex0 + 1, 0, col0));
}
else if (regionIndex0 == regionCount - 1 && col0 == (Region.COLS_PER_REGION - 1) / 2) {
//top portal only available from center column of topmost row
locations.add(new ConquestLocation(plane, regionCount, 0, col0));
}
//add location below
if (row0 > 0) {
locations.add(new ConquestLocation(plane, regionIndex0, row0 - 1, col0));
}
else if (regionIndex0 > 0) {
locations.add(new ConquestLocation(plane, regionIndex0 - 1, Region.ROWS_PER_REGION - 1, col0));
}
else if (regionIndex0 == 0 && col0 == (Region.COLS_PER_REGION - 1) / 2) {
//bottom portal only available from center column of bottommost row
locations.add(new ConquestLocation(plane, -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));
}
if (col0 < Region.COLS_PER_REGION - 1) {
locations.add(new ConquestLocation(plane, regionIndex0, row0, col0 + 1));
}
}
return locations;
}
}

View File

@@ -7,7 +7,8 @@ import forge.planarconquest.ConquestPlane.Region;
public class ConquestPlaneData {
private final ConquestPlane plane;
private final ConquestEventRecord[][][] records;
private final int[][][] eventResults;
private int bossResult;
private int wins, losses;
private int winStreakBest = 0;
@@ -15,11 +16,21 @@ public class ConquestPlaneData {
public ConquestPlaneData(ConquestPlane plane0) {
plane = plane0;
records = new ConquestEventRecord[plane.getRegions().size()][Region.ROWS_PER_REGION][Region.COLS_PER_REGION];
eventResults = new int[plane.getRegions().size()][Region.ROWS_PER_REGION][Region.COLS_PER_REGION];
}
public ConquestEventRecord getRecord(int regionIndex, int row, int col) {
return records[regionIndex][row][col];
public int getEventResult(int regionIndex, int row, int col) {
if (regionIndex == -1) {
return 1; //bottom portal is always conquered
}
if (regionIndex == plane.getRegions().size()) {
return bossResult;
}
return eventResults[regionIndex][row][col];
}
public int getBossResult() {
return bossResult;
}
public void addWin(ConquestCommander opponent) {