mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Start major Planar Conquest overhaul
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
package forge.achievement;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.item.IPaperCard;
|
||||
@@ -9,6 +12,10 @@ import forge.properties.ForgeConstants;
|
||||
public class PlaneswalkerAchievements extends AchievementCollection {
|
||||
public static final PlaneswalkerAchievements instance = new PlaneswalkerAchievements();
|
||||
|
||||
public static ISkinImage getTrophyImage(String planeswalkerName) {
|
||||
return GuiBase.getInterface().createLayeredImage(FSkinProp.IMG_SPECIAL_TROPHY, ForgeConstants.CACHE_ACHIEVEMENTS_DIR + "/" + planeswalkerName + ".png", 1);
|
||||
}
|
||||
|
||||
private PlaneswalkerAchievements() {
|
||||
super("Planeswalker Ultimates", ForgeConstants.ACHIEVEMENTS_DIR + "planeswalkers.xml", false);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ public enum FSkinProp {
|
||||
BG_SPLASH (null, PropType.BACKGROUND),
|
||||
BG_TEXTURE (null, PropType.BACKGROUND),
|
||||
BG_MATCH (null, PropType.BACKGROUND),
|
||||
BG_PLANAR_MAP (null, PropType.BACKGROUND),
|
||||
BG_MONITOR (null, PropType.BACKGROUND),
|
||||
|
||||
//colors
|
||||
CLR_THEME (new int[] {70, 10}, PropType.COLOR),
|
||||
@@ -243,6 +241,9 @@ public enum FSkinProp {
|
||||
IMG_TROPHY_CASE_TOP (new int[] {0, 185, 798, 38}, PropType.TROPHY),
|
||||
IMG_TROPHY_SHELF (new int[] {0, 223, 798, 257}, PropType.TROPHY),
|
||||
|
||||
//planar conquest images
|
||||
IMG_HEXAGON_TILE (new int[] {0, 0, 220, 192}, PropType.PLANAR_CONQUEST),
|
||||
|
||||
//button images
|
||||
IMG_BTN_START_UP (new int[] {480, 200, 160, 80}, PropType.ICON),
|
||||
IMG_BTN_START_OVER (new int[] {480, 280, 160, 80}, PropType.ICON),
|
||||
@@ -299,5 +300,6 @@ public enum FSkinProp {
|
||||
FOIL,
|
||||
OLD_FOIL,
|
||||
TROPHY,
|
||||
PLANAR_CONQUEST
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class ConquestPlaneData {
|
||||
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 ConquestPlaneMap map;
|
||||
|
||||
private int wins, losses;
|
||||
private int winStreakBest = 0;
|
||||
@@ -23,6 +24,7 @@ public class ConquestPlaneData {
|
||||
|
||||
public ConquestPlaneData(ConquestPlane plane0) {
|
||||
plane = plane0;
|
||||
map = new ConquestPlaneMap(plane0);
|
||||
}
|
||||
|
||||
public List<ConquestCommander> getCommanders() {
|
||||
@@ -92,6 +94,10 @@ public class ConquestPlaneData {
|
||||
return count;
|
||||
}
|
||||
|
||||
public ConquestPlaneMap getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public RegionData getRegionData(Region region) {
|
||||
RegionData regionData = regionDataLookup.get(region);
|
||||
if (regionData == null) {
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forge.util.Aggregates;
|
||||
|
||||
public class ConquestPlaneMap {
|
||||
//use 2 dimensional array to represent tile grid
|
||||
private final int gridSize;
|
||||
private final HexagonTile[][] grid;
|
||||
private int tileCount;
|
||||
|
||||
public ConquestPlaneMap(ConquestPlane plane) {
|
||||
int size = (int)Math.round(Math.sqrt(plane.getCardPool().size() / 3)); //use card pool size to determine grid size
|
||||
if (size % 2 == 0) {
|
||||
size++; //ensure grid size is an odd number
|
||||
}
|
||||
gridSize = size;
|
||||
grid = new HexagonTile[gridSize][gridSize];
|
||||
generateRandomGrid();
|
||||
}
|
||||
|
||||
private void generateRandomGrid() {
|
||||
int startQ = gridSize / 2; //player will start at center of grid always
|
||||
int startR = startQ;
|
||||
addTile(startQ, startR);
|
||||
|
||||
int max = gridSize - 1;
|
||||
int minCount = Math.round(gridSize * gridSize * 0.8f); //ensure at least 80% of the grid has tiles
|
||||
while (tileCount < minCount) {
|
||||
//add a tile in a random location and then ensure it can be reached from start tile
|
||||
int q = Aggregates.randomInt(0, max);
|
||||
int r = Aggregates.randomInt(0, max);
|
||||
while (addTile(q, r)) {
|
||||
//alternate which coordinate is incremented as we move towards center
|
||||
if (tileCount % 2 == 0 && r != startR) {
|
||||
if (r > startR) {
|
||||
r--;
|
||||
}
|
||||
else {
|
||||
r++;
|
||||
}
|
||||
}
|
||||
else if (q > startQ) {
|
||||
q--;
|
||||
}
|
||||
else if (q < startQ) {
|
||||
q++;
|
||||
}
|
||||
else if (r > startR) {
|
||||
r--;
|
||||
}
|
||||
else {
|
||||
r++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addTile(int q, int r) {
|
||||
if (grid[q][r] == null) {
|
||||
grid[q][r] = new HexagonTile(q, r);
|
||||
tileCount++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public class HexagonTile {
|
||||
private int q, r;
|
||||
|
||||
private HexagonTile(int q0, int r0) {
|
||||
q = q0;
|
||||
r = r0;
|
||||
}
|
||||
|
||||
public List<HexagonTile> getNeighbors() {
|
||||
List<HexagonTile> neighbors = new ArrayList<HexagonTile>();
|
||||
addToList(q, r - 1, neighbors); //tile above
|
||||
addToList(q, r + 1, neighbors); //tile below
|
||||
if (q % 2 == 0) {
|
||||
addToList(q - 1, r - 1, neighbors); //tile left and up
|
||||
addToList(q - 1, r, neighbors); //tile left and down
|
||||
addToList(q + 1, r - 1, neighbors); //tile right and up
|
||||
addToList(q + 1, r, neighbors); //tile right and down
|
||||
}
|
||||
else {
|
||||
addToList(q - 1, r, neighbors); //tile left and up
|
||||
addToList(q - 1, r + 1, neighbors); //tile left and down
|
||||
addToList(q + 1, r, neighbors); //tile right and up
|
||||
addToList(q + 1, r + 1, neighbors); //tile right and down
|
||||
}
|
||||
return neighbors;
|
||||
}
|
||||
}
|
||||
|
||||
private void addToList(int q, int r, List<HexagonTile> list) {
|
||||
if (r < 0 || q < 0 || q >= grid.length || r >= grid[0].length) {
|
||||
return;
|
||||
}
|
||||
HexagonTile tile = grid[q][r];
|
||||
if (tile != null) {
|
||||
list.add(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,12 +77,11 @@ public final class ForgeConstants {
|
||||
public static final String SPRITE_OLD_FOILS_FILE = "sprite_old_foils.png";
|
||||
public static final String SPRITE_TROPHIES_FILE = "sprite_trophies.png";
|
||||
public static final String SPRITE_AVATARS_FILE = "sprite_avatars.png";
|
||||
public static final String SPRITE_PLANAR_CONQUEST_FILE = "sprite_planar_conquest.png";
|
||||
public static final String FONT_FILE = "font1.ttf";
|
||||
public static final String SPLASH_BG_FILE = "bg_splash.png";
|
||||
public static final String MATCH_BG_FILE = "bg_match.jpg";
|
||||
public static final String TEXTURE_BG_FILE = "bg_texture.jpg";
|
||||
public static final String PLANAR_MAP_BG_FILE = "bg_planar_map.png";
|
||||
public static final String MONITOR_BG_FILE = "bg_monitor.png";
|
||||
public static final String DRAFT_DECK_IMG_FILE = "bg_draft_deck.png";
|
||||
|
||||
// data tree roots
|
||||
|
||||
Reference in New Issue
Block a user