mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
Support rendering grid overlays based on event record
This commit is contained in:
@@ -23,7 +23,6 @@ import forge.deck.Deck;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.ItemPool;
|
||||
|
||||
@@ -51,10 +50,10 @@ public final class ConquestData {
|
||||
private int progress = 100;
|
||||
private int planewalkerPosition = 0;
|
||||
private int difficulty;
|
||||
private ConquestPlane startingPlane, currentPlane;
|
||||
private int currentRegionIndex;
|
||||
private ConquestPlane startingPlane;
|
||||
private PaperCard planeswalker;
|
||||
private ISkinImage planeswalkerToken;
|
||||
private final ConquestLocation currentLocation = new ConquestLocation();
|
||||
private final EnumMap<ConquestPlane, ConquestPlaneData> planeDataMap = new EnumMap<ConquestPlane, ConquestPlaneData>(ConquestPlane.class);
|
||||
|
||||
private final HashSet<PaperCard> collection = new HashSet<PaperCard>();
|
||||
@@ -69,7 +68,7 @@ public final class ConquestData {
|
||||
name = name0;
|
||||
difficulty = difficulty0;
|
||||
startingPlane = startingPlane0;
|
||||
currentPlane = startingPlane0;
|
||||
currentLocation.travelToPlane(startingPlane);
|
||||
planeswalker = planeswalker0;
|
||||
planeswalkerToken = PlaneswalkerAchievements.getTrophyImage(planeswalker.getName());
|
||||
collection.add(planeswalker);
|
||||
@@ -103,10 +102,15 @@ public final class ConquestData {
|
||||
}
|
||||
|
||||
public ConquestPlane getCurrentPlane() {
|
||||
return currentPlane;
|
||||
return currentLocation.getPlane();
|
||||
}
|
||||
|
||||
public ConquestLocation getCurrentLocation() {
|
||||
return currentLocation;
|
||||
}
|
||||
|
||||
public ConquestPlaneData getCurrentPlaneData() {
|
||||
ConquestPlane currentPlane = getCurrentPlane();
|
||||
ConquestPlaneData planeData = planeDataMap.get(currentPlane);
|
||||
if (planeData == null) {
|
||||
planeData = new ConquestPlaneData(currentPlane);
|
||||
@@ -115,32 +119,6 @@ public final class ConquestData {
|
||||
return planeData;
|
||||
}
|
||||
|
||||
public Region getCurrentRegion() {
|
||||
return currentPlane.getRegions().get(currentRegionIndex);
|
||||
}
|
||||
public boolean setCurrentRegion(Region region) {
|
||||
int index = currentPlane.getRegions().indexOf(region);
|
||||
if (index != -1 && currentRegionIndex != index) {
|
||||
currentRegionIndex = index;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void incrementRegion(int dir) {
|
||||
if (dir > 0) {
|
||||
currentRegionIndex++;
|
||||
if (currentRegionIndex >= currentPlane.getRegions().size()) {
|
||||
currentRegionIndex = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
currentRegionIndex--;
|
||||
if (currentRegionIndex < 0) {
|
||||
currentRegionIndex = currentPlane.getRegions().size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<PaperCard> getCollection() {
|
||||
return collection;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
public class ConquestEvent {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
|
||||
public class ConquestLocation {
|
||||
private ConquestPlane plane;
|
||||
private int regionIndex;
|
||||
private int row;
|
||||
private int col;
|
||||
|
||||
public ConquestLocation() {
|
||||
}
|
||||
|
||||
public ConquestPlane getPlane() {
|
||||
return plane;
|
||||
}
|
||||
|
||||
public Region getRegion() {
|
||||
if (regionIndex == -1 || regionIndex == plane.getRegions().size()) {
|
||||
return null; //indicates we're on portal row
|
||||
}
|
||||
return plane.getRegions().get(regionIndex);
|
||||
}
|
||||
|
||||
public int getRegionIndex() {
|
||||
return regionIndex;
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return row;
|
||||
}
|
||||
|
||||
public int getCol() {
|
||||
return col;
|
||||
}
|
||||
|
||||
public void travelToPlane(ConquestPlane plane0) {
|
||||
if (plane == plane0) { return; }
|
||||
if (plane == null /*|| plane0 follows plane in travel order */) {
|
||||
regionIndex = -1; //start on bottom portal row
|
||||
}
|
||||
else {
|
||||
regionIndex = plane.getRegions().size(); //start on top portal row
|
||||
}
|
||||
plane = plane0;
|
||||
}
|
||||
|
||||
public List<ConquestLocation> getNeighbors() {
|
||||
return getNeighbors(regionIndex, row, col);
|
||||
}
|
||||
public List<ConquestLocation> getNeighbors(int regionIndex0, int row0, int col0) {
|
||||
List<ConquestLocation> locations = new ArrayList<ConquestLocation>();
|
||||
if (row0 > 0) {
|
||||
|
||||
}
|
||||
else if (regionIndex0 > 0) {
|
||||
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
}
|
||||
@@ -272,7 +272,8 @@ public enum ConquestPlane {
|
||||
}
|
||||
|
||||
public static class Region {
|
||||
public static final int OPPONENTS_PER_REGION = 15;
|
||||
public static final int ROWS_PER_REGION = 3;
|
||||
public static final int COLS_PER_REGION = 3;
|
||||
|
||||
private final String name;
|
||||
private final String artCardName;
|
||||
@@ -327,7 +328,7 @@ public enum ConquestPlane {
|
||||
|
||||
//each region should have 15 opponents include one boss
|
||||
private void generateOpponents() {
|
||||
int opponentsBeforeBoss = OPPONENTS_PER_REGION; //TODO: Reduce by 1 when boss added below
|
||||
int opponentsBeforeBoss = ROWS_PER_REGION * COLS_PER_REGION; //TODO: Reduce by 1 when boss added below
|
||||
HashSet<PaperCard> cards = new HashSet<PaperCard>(commanders);
|
||||
if (cards.size() < opponentsBeforeBoss) {
|
||||
//if not enough commanders, add normal creatures as non-commander opponents
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
|
||||
public class ConquestPlaneData {
|
||||
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
||||
private final Map<String, Integer> winsPerOpponent = new HashMap<String, Integer>();
|
||||
private final Map<String, Integer> lossesPerOpponent = new HashMap<String, Integer>();
|
||||
private final ConquestPlane plane;
|
||||
private final ConquestEventRecord[][][] records;
|
||||
|
||||
private int wins, losses;
|
||||
private int winStreakBest = 0;
|
||||
@@ -21,29 +15,11 @@ public class ConquestPlaneData {
|
||||
|
||||
public ConquestPlaneData(ConquestPlane plane0) {
|
||||
plane = plane0;
|
||||
records = new ConquestEventRecord[plane.getRegions().size()][Region.ROWS_PER_REGION][Region.COLS_PER_REGION];
|
||||
}
|
||||
|
||||
public List<ConquestCommander> getCommanders() {
|
||||
return commanders;
|
||||
}
|
||||
|
||||
public boolean hasCommander(PaperCard pc) {
|
||||
for (ConquestCommander c : commanders) {
|
||||
if (c.getCard() == pc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getWinsAgainst(PaperCard pc) {
|
||||
Integer wins = winsPerOpponent.get(pc.getName());
|
||||
return wins == null ? 0 : wins.intValue();
|
||||
}
|
||||
|
||||
public int getLossesAgainst(PaperCard pc) {
|
||||
Integer losses = lossesPerOpponent.get(pc.getName());
|
||||
return losses == null ? 0 : losses.intValue();
|
||||
public ConquestEventRecord getRecord(int regionIndex, int row, int col) {
|
||||
return records[regionIndex][row][col];
|
||||
}
|
||||
|
||||
public void addWin(ConquestCommander opponent) {
|
||||
@@ -52,13 +28,11 @@ public class ConquestPlaneData {
|
||||
if (winStreakCurrent > winStreakBest) {
|
||||
winStreakBest = winStreakCurrent;
|
||||
}
|
||||
winsPerOpponent.put(opponent.getName(), getWinsAgainst(opponent.getCard()) + 1);
|
||||
}
|
||||
|
||||
public void addLoss(ConquestCommander opponent) {
|
||||
losses++;
|
||||
winStreakCurrent = 0;
|
||||
lossesPerOpponent.put(opponent.getName(), getLossesAgainst(opponent.getCard()) + 1);
|
||||
}
|
||||
|
||||
public int getWins() {
|
||||
|
||||
Reference in New Issue
Block a user