mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Add fog of war support and planar portal image
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -18291,7 +18291,6 @@ forge-gui/src/main/java/forge/planarconquest/ConquestData.java -text
|
|||||||
forge-gui/src/main/java/forge/planarconquest/ConquestDataIO.java -text
|
forge-gui/src/main/java/forge/planarconquest/ConquestDataIO.java -text
|
||||||
forge-gui/src/main/java/forge/planarconquest/ConquestDeckMap.java -text
|
forge-gui/src/main/java/forge/planarconquest/ConquestDeckMap.java -text
|
||||||
forge-gui/src/main/java/forge/planarconquest/ConquestEvent.java -text
|
forge-gui/src/main/java/forge/planarconquest/ConquestEvent.java -text
|
||||||
forge-gui/src/main/java/forge/planarconquest/ConquestEventRecord.java -text
|
|
||||||
forge-gui/src/main/java/forge/planarconquest/ConquestLocation.java -text
|
forge-gui/src/main/java/forge/planarconquest/ConquestLocation.java -text
|
||||||
forge-gui/src/main/java/forge/planarconquest/ConquestOpponent.java -text
|
forge-gui/src/main/java/forge/planarconquest/ConquestOpponent.java -text
|
||||||
forge-gui/src/main/java/forge/planarconquest/ConquestPlane.java -text
|
forge-gui/src/main/java/forge/planarconquest/ConquestPlane.java -text
|
||||||
|
|||||||
@@ -116,14 +116,8 @@ public enum FSkinImage implements FImage {
|
|||||||
TROPHY_CASE_TOP (FSkinProp.IMG_TROPHY_CASE_TOP, SourceFile.TROPHIES),
|
TROPHY_CASE_TOP (FSkinProp.IMG_TROPHY_CASE_TOP, SourceFile.TROPHIES),
|
||||||
TROPHY_SHELF (FSkinProp.IMG_TROPHY_SHELF, SourceFile.TROPHIES),
|
TROPHY_SHELF (FSkinProp.IMG_TROPHY_SHELF, SourceFile.TROPHIES),
|
||||||
|
|
||||||
//Planar Conquest Tiles
|
//Planar Conquest Images
|
||||||
HEXAGON_TILE (FSkinProp.IMG_HEXAGON_TILE, SourceFile.PLANAR_CONQUEST),
|
PLANAR_PORTAL (FSkinProp.IMG_PLANAR_PORTAL, SourceFile.PLANAR_CONQUEST),
|
||||||
COLORLESS_TILE (FSkinProp.IMG_COLORLESS_TILE, SourceFile.PLANAR_CONQUEST),
|
|
||||||
WHITE_TILE (FSkinProp.IMG_WHITE_TILE, SourceFile.PLANAR_CONQUEST),
|
|
||||||
BLUE_TILE (FSkinProp.IMG_BLUE_TILE, SourceFile.PLANAR_CONQUEST),
|
|
||||||
BLACK_TILE (FSkinProp.IMG_BLACK_TILE, SourceFile.PLANAR_CONQUEST),
|
|
||||||
RED_TILE (FSkinProp.IMG_RED_TILE, SourceFile.PLANAR_CONQUEST),
|
|
||||||
GREEN_TILE (FSkinProp.IMG_GREEN_TILE, SourceFile.PLANAR_CONQUEST),
|
|
||||||
|
|
||||||
//Quest Icons
|
//Quest Icons
|
||||||
QUEST_ZEP (FSkinProp.ICO_QUEST_ZEP, SourceFile.ICONS),
|
QUEST_ZEP (FSkinProp.ICO_QUEST_ZEP, SourceFile.ICONS),
|
||||||
|
|||||||
@@ -7,12 +7,12 @@ import com.badlogic.gdx.graphics.Color;
|
|||||||
import forge.Graphics;
|
import forge.Graphics;
|
||||||
import forge.assets.FImage;
|
import forge.assets.FImage;
|
||||||
import forge.assets.FSkinColor;
|
import forge.assets.FSkinColor;
|
||||||
|
import forge.assets.FSkinImage;
|
||||||
import forge.card.CardDetailUtil;
|
import forge.card.CardDetailUtil;
|
||||||
import forge.card.CardRenderer;
|
import forge.card.CardRenderer;
|
||||||
import forge.card.CardDetailUtil.DetailColors;
|
import forge.card.CardDetailUtil.DetailColors;
|
||||||
import forge.model.FModel;
|
import forge.model.FModel;
|
||||||
import forge.planarconquest.ConquestData;
|
import forge.planarconquest.ConquestData;
|
||||||
import forge.planarconquest.ConquestEventRecord;
|
|
||||||
import forge.planarconquest.ConquestLocation;
|
import forge.planarconquest.ConquestLocation;
|
||||||
import forge.planarconquest.ConquestPlane.Region;
|
import forge.planarconquest.ConquestPlane.Region;
|
||||||
import forge.planarconquest.ConquestPlaneData;
|
import forge.planarconquest.ConquestPlaneData;
|
||||||
@@ -86,17 +86,31 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
|
|
||||||
g.startClip(0, 0, w, h);
|
g.startClip(0, 0, w, h);
|
||||||
|
|
||||||
|
Color color;
|
||||||
float x = 0;
|
float x = 0;
|
||||||
float y = -getScrollTop();
|
float y = -getScrollTop();
|
||||||
|
float colLineStartY = 0;
|
||||||
|
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) {
|
||||||
g.fillRect(Color.MAGENTA, 0, y, w, rowHeight);
|
g.drawImage(FSkinImage.PLANAR_PORTAL, 0, y, w, rowHeight);
|
||||||
|
if (planeData.getBossResult() == 0) { //draw overlay if boss hasn't been beaten yet
|
||||||
|
if (planeData.getEventResult(regionCount - 1, rows - 1, (cols - 1) / 2) > 0) {
|
||||||
|
color = UNCONQUERED_COLOR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = FOG_OF_WAR_COLOR;
|
||||||
|
}
|
||||||
|
g.fillRect(color, 0, y, w, rowHeight);
|
||||||
|
}
|
||||||
|
colLineStartY = y + rowHeight;
|
||||||
}
|
}
|
||||||
y += rowHeight;
|
y += rowHeight;
|
||||||
|
|
||||||
FCollectionView<Region> regions = model.getCurrentPlane().getRegions();
|
for (int i = regionCount - 1; i >= 0; i--) {
|
||||||
for (int i = regions.size() - 1; i >= 0; i--) {
|
|
||||||
if (y + regionHeight <= 0) {
|
if (y + regionHeight <= 0) {
|
||||||
y += regionHeight;
|
y += regionHeight;
|
||||||
continue;
|
continue;
|
||||||
@@ -129,25 +143,19 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
//draw event icon and overlay based on event record for each event in the region
|
//draw event icon and overlay based on event record for each event in the region
|
||||||
for (int r = 0; r < rows; r++) {
|
for (int r = 0; r < rows; r++) {
|
||||||
for (int c = 0; c < cols; c++) {
|
for (int c = 0; c < cols; c++) {
|
||||||
ConquestEventRecord record = planeData.getRecord(i, r, c);
|
if (planeData.getEventResult(i, r, c) == 0) {
|
||||||
if (record == null || record.getWins() == 0) {
|
|
||||||
//draw fog of war by default if area hasn't been conquered
|
//draw fog of war by default if area hasn't been conquered
|
||||||
Color 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 : currentLocation.getNeighbors(i, r, c)) {
|
||||||
if (loc.getRegion() == null) {
|
if (planeData.getEventResult(loc.getRegionIndex(), loc.getRow(), loc.getCol()) > 0) {
|
||||||
color = UNCONQUERED_COLOR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
record = planeData.getRecord(loc.getRegionIndex(), loc.getRow(), loc.getCol());
|
|
||||||
if (record != null && record.getWins() > 0) {
|
|
||||||
color = UNCONQUERED_COLOR;
|
color = UNCONQUERED_COLOR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g.fillRect(color, x + c * colWidth, y + r * rowHeight, colWidth, rowHeight);
|
g.fillRect(color, x + c * colWidth, y + (rows - r - 1) * rowHeight, colWidth, rowHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,14 +172,15 @@ public class ConquestMapScreen extends FScreen {
|
|||||||
|
|
||||||
//draw bottom portal row
|
//draw bottom portal row
|
||||||
if (y <= h) {
|
if (y <= h) {
|
||||||
g.fillRect(Color.MAGENTA, 0, y, w, rowHeight);
|
g.drawImage(FSkinImage.PLANAR_PORTAL, 0, y, w, rowHeight);
|
||||||
g.drawLine(1, Color.BLACK, 0, y, w, y);
|
g.drawLine(1, Color.BLACK, 0, y, w, y);
|
||||||
|
colLineEndY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw column lines
|
//draw column lines
|
||||||
float x0 = x + colWidth;
|
float x0 = x + colWidth;
|
||||||
for (int c = 1; c < cols; c++) {
|
for (int c = 1; c < cols; c++) {
|
||||||
g.drawLine(1, Color.BLACK, x0, 0, x0, h);
|
g.drawLine(1, Color.BLACK, x0, colLineStartY, x0, colLineEndY);
|
||||||
x0 += colWidth;
|
x0 += colWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 172 KiB After Width: | Height: | Size: 40 KiB |
@@ -243,13 +243,7 @@ public enum FSkinProp {
|
|||||||
IMG_TROPHY_SHELF (new int[] {0, 223, 798, 257}, PropType.TROPHY),
|
IMG_TROPHY_SHELF (new int[] {0, 223, 798, 257}, PropType.TROPHY),
|
||||||
|
|
||||||
//planar conquest images
|
//planar conquest images
|
||||||
IMG_HEXAGON_TILE (new int[] {354, 0, 151, 173}, PropType.PLANAR_CONQUEST),
|
IMG_PLANAR_PORTAL (new int[] {0, 0, 293, 75}, 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),
|
|
||||||
|
|
||||||
//button images
|
//button images
|
||||||
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),
|
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -14,6 +14,13 @@ public class ConquestLocation {
|
|||||||
public ConquestLocation() {
|
public ConquestLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ConquestLocation(ConquestPlane plane0, int regionIndex0, int row0, int col0) {
|
||||||
|
plane = plane0;
|
||||||
|
regionIndex = regionIndex0;
|
||||||
|
row = row0;
|
||||||
|
col = col0;
|
||||||
|
}
|
||||||
|
|
||||||
public ConquestPlane getPlane() {
|
public ConquestPlane getPlane() {
|
||||||
return plane;
|
return plane;
|
||||||
}
|
}
|
||||||
@@ -52,13 +59,43 @@ public class ConquestLocation {
|
|||||||
return getNeighbors(regionIndex, row, col);
|
return getNeighbors(regionIndex, row, col);
|
||||||
}
|
}
|
||||||
public List<ConquestLocation> getNeighbors(int regionIndex0, int row0, int col0) {
|
public List<ConquestLocation> getNeighbors(int regionIndex0, int row0, int col0) {
|
||||||
|
int regionCount = plane.getRegions().size();
|
||||||
List<ConquestLocation> locations = new ArrayList<ConquestLocation>();
|
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) {
|
if (row0 > 0) {
|
||||||
|
locations.add(new ConquestLocation(plane, 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));
|
||||||
}
|
}
|
||||||
|
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;
|
return locations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import forge.planarconquest.ConquestPlane.Region;
|
|||||||
|
|
||||||
public class ConquestPlaneData {
|
public class ConquestPlaneData {
|
||||||
private final ConquestPlane plane;
|
private final ConquestPlane plane;
|
||||||
private final ConquestEventRecord[][][] records;
|
private final int[][][] eventResults;
|
||||||
|
private int bossResult;
|
||||||
|
|
||||||
private int wins, losses;
|
private int wins, losses;
|
||||||
private int winStreakBest = 0;
|
private int winStreakBest = 0;
|
||||||
@@ -15,11 +16,21 @@ public class ConquestPlaneData {
|
|||||||
|
|
||||||
public ConquestPlaneData(ConquestPlane plane0) {
|
public ConquestPlaneData(ConquestPlane plane0) {
|
||||||
plane = 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) {
|
public int getEventResult(int regionIndex, int row, int col) {
|
||||||
return records[regionIndex][row][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) {
|
public void addWin(ConquestCommander opponent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user