Support dividing map into regions

This commit is contained in:
drdev
2014-12-18 02:46:41 +00:00
parent d07072af8e
commit d8e146b409
2 changed files with 153 additions and 192 deletions

View File

@@ -20,14 +20,14 @@ package forge.planarconquest;
import java.util.HashSet;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import forge.GuiBase;
import forge.assets.ISkinImage;
import forge.card.CardEdition;
import forge.card.CardRules;
import forge.card.CardRulesPredicates;
import forge.card.CardEdition.CardInSet;
import forge.card.CardType;
import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.deck.generation.DeckGenPool;
import forge.item.PaperCard;
@@ -41,16 +41,11 @@ public enum ConquestPlane {
Alara("Alara", new String[] {
"ALA", "CON", "ARB"
}, new Region[] {
new Region("Bant {G}{W}{U}", "Seaside Citadel", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.WHITE | MagicColor.BLUE),
new String[] { "Bant" }),
new Region("Esper {W}{U}{B}", "Arcane Sanctum", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLUE | MagicColor.BLACK),
new String[] { "Esper" }),
new Region("Grixis {U}{B}{R}", "Crumbling Necropolis", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.BLACK | MagicColor.RED),
new String[] { "Grixis" }),
new Region("Jund {B}{R}{G}", "Savage Lands", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.RED | MagicColor.GREEN),
new String[] { "Jund" }),
new Region("Naya {R}{G}{W}", "Jungle Shrine", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.GREEN | MagicColor.WHITE),
new String[] { "Naya" })
new Region("Bant", "Bant Panorama", MagicColor.GREEN | MagicColor.WHITE | MagicColor.BLUE),
new Region("Esper", "Esper Panorama", MagicColor.WHITE | MagicColor.BLUE | MagicColor.BLACK),
new Region("Grixis", "Grixis Panorama", MagicColor.BLUE | MagicColor.BLACK | MagicColor.RED),
new Region("Jund", "Jund Panorama", MagicColor.BLACK | MagicColor.RED | MagicColor.GREEN),
new Region("Naya", "Naya Panorama", MagicColor.RED | MagicColor.GREEN | MagicColor.WHITE)
}),
Dominaria("Dominaria", new String[] {
"ICE", "ALL", "CSP",
@@ -70,144 +65,89 @@ public enum ConquestPlane {
Innistrad("Innistrad", new String[] {
"ISD", "DKA", "AVR"
}, new Region[] {
new Region("Moorland {W}{U}", "Moorland Haunt", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLUE),
new String[] { "Moorland" }),
new Region("Nephalia {U}{B}", "Nephalia Drownyard", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.BLACK),
new String[] { "Nephalia" }),
new Region("Stensia {B}{R}", "Stensia Bloodhall", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.RED),
new String[] { "Stensia" }),
new Region("Kessig {R}{G}", "Kessig Wolf Run", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.GREEN),
new String[] { "Kessig" }),
new Region("Gavony {G}{W}", "Gavony Township", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.WHITE),
new String[] { "Gavony" })
new Region("Moorland", "Moorland Haunt", MagicColor.WHITE | MagicColor.BLUE),
new Region("Nephalia", "Nephalia Drownyard", MagicColor.BLUE | MagicColor.BLACK),
new Region("Stensia", "Stensia Bloodhall", MagicColor.BLACK | MagicColor.RED),
new Region("Kessig", "Kessig Wolf Run", MagicColor.RED | MagicColor.GREEN),
new Region("Gavony", "Gavony Township", MagicColor.GREEN | MagicColor.WHITE),
}),
Jamuraa("Jamuraa", new String[] {
"MIR", "VIS", "WTH"
}, new Region[] {
new Region("Karoo {W}", "Karoo", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE),
new String[] { "Karoo" }),
new Region("Coral Atoll {U}", "Coral Atoll", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE),
new String[] { "Coral" }),
new Region("Everglades {B}", "Everglades", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK),
new String[] { "Everglades" }),
new Region("Dormant Volcano {R}", "Dormant Volcano", CardRulesPredicates.hasColorIdentity(MagicColor.RED),
new String[] { "Volcano" }),
new Region("Jungle Basin {G}", "Jungle Basin", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN),
new String[] { "Jungle" })
new Region("Karoo", "Karoo", MagicColor.WHITE),
new Region("Coral Atoll", "Coral Atoll", MagicColor.BLUE),
new Region("Everglades", "Everglades", MagicColor.BLACK),
new Region("Dormant Volcano", "Dormant Volcano", MagicColor.RED),
new Region("Jungle Basin", "Jungle Basin", MagicColor.GREEN),
}),
Kamigawa("Kamigawa", new String[] {
"CHK", "BOK", "SOK"
}, new Region[] {
new Region("Towabara {W}", "Eiganjo Castle", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE),
new String[] { "Towabara", "Eiganjo", "Plains" }),
new Region("Minamo Academy {U}", "Minamo, School at Water's Edge", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE),
new String[] { "Minamo", "Water", "Island" }),
new Region("Takenuma {B}", "Shizo, Death's Storehouse", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK),
new String[] { "Takenuma", "Shizo", "Swamp" }),
new Region("Sokenzan Mountains {R}", "Shinka, the Bloodsoaked Keep", CardRulesPredicates.hasColorIdentity(MagicColor.RED),
new String[] { "Sokenzan", "Shinka", "Mountain" }),
new Region("Jukai Forest {G}", "Okina, Temple to the Grandfathers", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN),
new String[] { "Jukai", "Okina", "Forest" })
new Region("Towabara", "Eiganjo Castle", MagicColor.WHITE),
new Region("Minamo Academy", "Minamo, School at Water's Edge", MagicColor.BLUE),
new Region("Takenuma", "Shizo, Death's Storehouse", MagicColor.BLACK),
new Region("Sokenzan Mountains", "Shinka, the Bloodsoaked Keep", MagicColor.RED),
new Region("Jukai Forest", "Okina, Temple to the Grandfathers", MagicColor.GREEN),
}),
LorwynShadowmoor("Lorwyn-Shadowmoor", new String[] {
"LRW", "MOR", "SHM", "EVE"
}, new Region[] {
new Region("Ancient Amphitheater {R}{W}", "Ancient Amphitheater", CardRulesPredicates.hasCreatureType("Giant"),
new String[] { }),
new Region("Auntie's Hovel {B}{R}", "Auntie's Hovel", CardRulesPredicates.hasCreatureType("Goblin"),
new String[] { "Auntie", "Boggart", "Hobgoblin", "Redcap", "Spriggan" }),
new Region("Gilt-Leaf Palace {B}{G}", "", CardRulesPredicates.hasCreatureType("Elf"),
new String[] { "Gilt-Leaf", "Elves", "Wilt-Leaf" }),
new Region("Murmuring Bosk {W}{B}{G}", "Murmuring Bosk", CardRulesPredicates.hasCreatureType("Treefolk"),
new String[] { "Bosk", "Treefolk" }),
new Region("Primal Beyond {W}{U}{B}{R}{G}", "Primal Beyond", CardRulesPredicates.hasCreatureType("Elemental"),
new String[] { "Elemental", "Flamekin", "Tanufel", "Cinder", "Kulrath" }),
new Region("Rustic Clachan {W}", "Rustic Clachan", CardRulesPredicates.hasCreatureType("Kithkin"),
new String[] { "Ballynock", "Ballyrush", "Barrenton", "Burrenton", "Cloverdell", "Goldmeadow", "Kinsbaile", "Kinscaer", "Mistmeadow" }),
new Region("Secluded Glen {U}{B}", "Secluded Glen", CardRulesPredicates.hasCreatureType("Faerie"),
new String[] { "Glen", "Oona", "Fae" }),
new Region("Wanderwine Hub {W}{U}", "Wanderwine Hub", CardRulesPredicates.hasCreatureType("Merfolk"),
new String[] { "Merrow", "Selkie", "Pirate" }),
new Region("Ancient Amphitheater", "Ancient Amphitheater", MagicColor.RED | MagicColor.WHITE),
new Region("Auntie's Hovel", "Auntie's Hovel", MagicColor.BLACK | MagicColor.RED),
new Region("Gilt-Leaf Palace", "Gilt-Leaf Palace", MagicColor.BLACK | MagicColor.GREEN),
new Region("Murmuring Bosk", "Murmuring Bosk", MagicColor.WHITE | MagicColor.BLACK | MagicColor.GREEN),
new Region("Primal Beyond", "Primal Beyond", MagicColor.ALL_COLORS),
new Region("Rustic Clachan", "Rustic Clachan", MagicColor.GREEN | MagicColor.WHITE),
new Region("Secluded Glen", "Secluded Glen", MagicColor.BLUE | MagicColor.BLACK),
new Region("Wanderwine Hub", "Wanderwine Hub", MagicColor.WHITE | MagicColor.BLUE),
}),
Mercadia("Mercadia", new String[] {
"MMQ", "NEM", "PCY"
}, new Region[] {
new Region("Fountain of Cho {W}", "Fountain of Cho", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE),
new String[] { "Cho" }),
new Region("Saprazzan Cove {U}", "Saprazzan Cove", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE),
new String[] { "Saprazzan", "Saprazzo" }),
new Region("Subterranean Hangar {B}", "Subterranean Hangar", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK),
new String[] { "Subterranean" }),
new Region("Mercadian Bazaar {R}", "Mercadian Bazaar", CardRulesPredicates.hasColorIdentity(MagicColor.RED),
new String[] { "Mercadian" }),
new Region("Rushwood Grove {G}", "Rushwood Grove", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN),
new String[] { "Rushwood" })
new Region("Fountain of Cho", "Fountain of Cho", MagicColor.WHITE),
new Region("Saprazzan Cove", "Saprazzan Cove", MagicColor.BLUE),
new Region("Subterranean Hangar", "Subterranean Hangar", MagicColor.BLACK),
new Region("Mercadian Bazaar", "Mercadian Bazaar", MagicColor.RED),
new Region("Rushwood Grove", "Rushwood Grove", MagicColor.GREEN)
}),
Mirrodin("Mirrodin", new String[] {
"MRD", "DST", "5DN", "SOM", "MBS", "NPH"
}, new Region[] {
new Region("Panopticon {X}", "Darksteel Citadel", CardRulesPredicates.Presets.IS_ARTIFACT,
new String[] { "Darksteel" }),
new Region("Taj-Nar {W}", "Ancient Den", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE),
new String[] { "Razor", "Fields", "Plains" }),
new Region("Lumengrid {U}", "Seat of the Synod", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE),
new String[] { "Quicksilver", "Sea", "Island" }),
new Region("Ish Sah {B}", "Vault of Whispers", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK),
new String[] { "Dross", "Mephidross" }),
new Region("Kuldotha {R}", "Great Furnace", CardRulesPredicates.hasColorIdentity(MagicColor.RED),
new String[] { "Oxidda", "Chain", "Mountain" }),
new Region("Tel-Jilad {G}", "Tree of Tales", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN),
new String[] { "Tangle", "Forest" }),
new Region("Glimmervoid {W}{U}{B}{R}{G}", "Glimmervoid", CardRulesPredicates.hasKeyword("Sunburst"),
new String[] { "Glimmervoid" }),
new Region("Panopticon", "Darksteel Citadel", MagicColor.COLORLESS),
new Region("Taj-Nar", "Ancient Den", MagicColor.WHITE),
new Region("Lumengrid", "Seat of the Synod", MagicColor.BLUE),
new Region("Ish Sah", "Vault of Whispers", MagicColor.BLACK),
new Region("Kuldotha", "Great Furnace", MagicColor.RED),
new Region("Tel-Jilad", "Tree of Tales", MagicColor.GREEN),
new Region("Glimmervoid", "Glimmervoid", MagicColor.ALL_COLORS)
}),
Rath("Rath", new String[] {
"TMP", "STH", "EXO"
}, new Region[] {
new Region("Caldera Lake {U}{R}", "Caldera Lake", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.RED),
new String[] { "Caldera" }),
new Region("Cinder Marsh {B}{R}", "Cinder Marsh", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.RED),
new String[] { "Cinder", "Marsh" }),
new Region("Mogg Hollows {R}{G}", "Mogg Hollows", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.GREEN),
new String[] { "Mogg", "Hollow" }),
new Region("Pine Barrens {B}{G}", "Pine Barrens", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.GREEN),
new String[] { "Barrens" }),
new Region("Rootwater Depths {U}{B}", "Rootwater Depths", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.BLACK),
new String[] { "Rootwater" }),
new Region("Salt Flats {W}{B}", "Salt Flats", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLACK),
new String[] { "Salt Flat" }),
new Region("Scabland {R}{W}", "Scabland", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.WHITE),
new String[] { "Scabland" }),
new Region("Skyshroud Forest {G}{U}", "Skyshroud Forest", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.BLUE),
new String[] { "Skyshroud" }),
new Region("Thalakos Lowlands {W}{U}", "Thalakos Lowlands", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLUE),
new String[] { "Thalakos" }),
new Region("Vec Townships {G}{W}", "Vec Townships", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.WHITE),
new String[] { "Vec" })
new Region("Caldera Lake", "Caldera Lake", MagicColor.BLUE | MagicColor.RED),
new Region("Cinder Marsh", "Cinder Marsh", MagicColor.BLACK | MagicColor.RED),
new Region("Mogg Hollows", "Mogg Hollows", MagicColor.RED | MagicColor.GREEN),
new Region("Pine Barrens", "Pine Barrens", MagicColor.BLACK | MagicColor.GREEN),
new Region("Rootwater Depths", "Rootwater Depths", MagicColor.BLUE | MagicColor.BLACK),
new Region("Salt Flats", "Salt Flats", MagicColor.WHITE | MagicColor.BLACK),
new Region("Scabland", "Scabland", MagicColor.RED | MagicColor.WHITE),
new Region("Skyshroud Forest", "Skyshroud Forest", MagicColor.GREEN | MagicColor.BLUE),
new Region("Thalakos Lowlands", "Thalakos Lowlands", MagicColor.WHITE | MagicColor.BLUE),
new Region("Vec Townships", "Vec Townships", MagicColor.GREEN | MagicColor.WHITE)
}),
Ravnica("Ravnica", new String[] {
"RAV", "GPT", "DIS", "RTR", "GTC", "DGM"
}, new Region[] {
new Region("Azorius Chancery {W}{U}", "Azorius Chancery", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLUE),
new String[] { "Azorius" }),
new Region("Boros Garrison {R}{W}", "Boros Garrison", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.WHITE),
new String[] { "Boros" }),
new Region("Dimir Aqueduct {U}{B}", "Dimir Aqueduct", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.BLACK),
new String[] { "Dimir" }),
new Region("Golgari Rot Farm {B}{G}", "Golgari Rot Farm", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.GREEN),
new String[] { "Golgari" }),
new Region("Gruul Turf {R}{G}", "Gruul Turf", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.GREEN),
new String[] { "Gruul" }),
new Region("Izzet Boilerworks {U}{R}", "Izzet Boilerworks", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.RED),
new String[] { "Izzet" }),
new Region("Orzhov Basilica {W}{B}", "Orzhov Basilica", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLACK),
new String[] { "Orzhov" }),
new Region("Rakdos Carnarium {R}{B}", "Rakdos Carnarium", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.RED),
new String[] { "Rakdos" }),
new Region("Selesnya Sanctuary {G}{W}", "Selesnya Sanctuary", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.WHITE),
new String[] { "Selesnya" }),
new Region("Simic Growth Chamber {G}{U}", "Simic Growth Chamber", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.BLUE),
new String[] { "Simic" })
new Region("Azorius Chancery", "Azorius Chancery", MagicColor.WHITE | MagicColor.BLUE),
new Region("Boros Garrison", "Boros Garrison", MagicColor.RED | MagicColor.WHITE),
new Region("Dimir Aqueduct", "Dimir Aqueduct", MagicColor.BLUE | MagicColor.BLACK),
new Region("Golgari Rot Farm", "Golgari Rot Farm", MagicColor.BLACK | MagicColor.GREEN),
new Region("Gruul Turf", "Gruul Turf", MagicColor.RED | MagicColor.GREEN),
new Region("Izzet Boilerworks", "Izzet Boilerworks", MagicColor.BLUE | MagicColor.RED),
new Region("Orzhov Basilica", "Orzhov Basilica", MagicColor.WHITE | MagicColor.BLACK),
new Region("Rakdos Carnarium", "Rakdos Carnarium", MagicColor.BLACK | MagicColor.RED),
new Region("Selesnya Sanctuary", "Selesnya Sanctuary", MagicColor.GREEN | MagicColor.WHITE),
new Region("Simic Growth Chamber", "Simic Growth Chamber", MagicColor.GREEN | MagicColor.BLUE)
}),
Shandalar("Shandalar", new String[] {
"2ED", "3ED", "4ED", "ARN", "ATQ", "LEG", "DRK"
@@ -221,34 +161,26 @@ public enum ConquestPlane {
Tarkir("Tarkir", new String[] {
"KTK", "FRF", "DTK"
}, new Region[] {
new Region("Abzan Houses {W}{B}{G}", "Sandsteppe Citadel", CardRulesPredicates.hasColorIdentity(MagicColor.WHITE | MagicColor.BLACK | MagicColor.GREEN),
new String[] { "Abzan", "House", "Citadel", "Arashin", "Wastes", "Mer-Ek" }),
new Region("Jeskai Way {U}{R}{W}", "Mystic Monastery", CardRulesPredicates.hasColorIdentity(MagicColor.BLUE | MagicColor.RED | MagicColor.WHITE),
new String[] { "Jeskai", "Way", "Mystic", "Monastery", "Stronghold", "Purugir" }),
new Region("Mardu Horde {R}{W}{B}", "Nomad Outpost", CardRulesPredicates.hasColorIdentity(MagicColor.RED | MagicColor.WHITE | MagicColor.BLACK),
new String[] { "Mardu", "Horde", "Nomad", "Outpost", "Wingthrone", "Goldengrave", "Scour", "Screamreach" }),
new Region("Sultai Brood {B}{G}{U}", "Opulent Palace", CardRulesPredicates.hasColorIdentity(MagicColor.BLACK | MagicColor.GREEN | MagicColor.BLUE),
new String[] { "Sultai", "Brood", "Opulent", "Palace", "Sagu", "Jungle", "Kheru", "Gudul", "Gurmag", "Marang" }),
new Region("Temur Frontier {G}{U}{R}", "Frontier Bivouac", CardRulesPredicates.hasColorIdentity(MagicColor.GREEN | MagicColor.BLUE | MagicColor.RED),
new String[] { "Temur", "Frontier", "Bivouac", "Qal Sisma", "Dragon's Throat", "Karakyk Valley", "Staircase of Bones" })
new Region("Abzan Houses", "Sandsteppe Citadel", MagicColor.WHITE | MagicColor.BLACK | MagicColor.GREEN),
new Region("Jeskai Way", "Mystic Monastery", MagicColor.BLUE | MagicColor.RED | MagicColor.WHITE),
new Region("Mardu Horde", "Nomad Outpost", MagicColor.RED | MagicColor.WHITE | MagicColor.BLACK),
new Region("Sultai Brood", "Opulent Palace", MagicColor.BLACK | MagicColor.GREEN | MagicColor.BLUE),
new Region("Temur Frontier", "Frontier Bivouac", MagicColor.GREEN | MagicColor.BLUE | MagicColor.RED)
}),
Theros("Theros", new String[] {
"THS", "BNG", "JOU"
}, new Region[] {
new Region("", "", null,
new String[] { }),
new Region("", "", inSet("THS", "BNG", "JOU"))
}),
Ulgrotha("Ulgrotha", new String[] {
"HML"
}, new Region[] {
new Region("", "", null,
new String[] { }),
new Region("", "", inSet("HML"))
}),
Zendikar("Zendikar", new String[] {
"ZEN", "WWK", "ROE"
}, new Region[] {
new Region("", "", null,
new String[] { }),
new Region("", "", inSet("ZEN", "WWK", "ROE"))
});
private final String name;
@@ -342,32 +274,29 @@ public enum ConquestPlane {
public static class Region {
private final String name;
private final String artCardName;
private final ColorSet colorSet;
private final Predicate<PaperCard> pred;
private final DeckGenPool cardPool = new DeckGenPool();
private final FCollection<PaperCard> commanders = new FCollection<PaperCard>();
private ISkinImage art;
private Region(String name0, String artCardName0, final int colorMask) {
name = name0;
artCardName = artCardName0;
pred = new Predicate<PaperCard>() {
@Override
public boolean apply(PaperCard pc) {
return pc.getRules().getColorIdentity().hasNoColorsExcept(colorMask);
}
};
colorSet = ColorSet.fromMask(colorMask);
}
private Region(String name0, String artCardName0, Predicate<PaperCard> pred0) {
name = name0;
artCardName = artCardName0;
pred = pred0;
}
private Region(String name0, String artCardName0, final Predicate<CardRules> rulesPred, final String[] keywords) {
this(name0, artCardName0, new Predicate<PaperCard>() {
@Override
public boolean apply(PaperCard pc) {
if (rulesPred != null && rulesPred.apply(pc.getRules())) {
return true;
}
for (String s : keywords) {
if (pc.getName().contains(s)) {
return true;
}
}
return false;
}
});
colorSet = ColorSet.fromMask(MagicColor.ALL_COLORS);
}
public String getName() {
@@ -381,6 +310,10 @@ public enum ConquestPlane {
return art;
}
public ColorSet getColorSet() {
return colorSet;
}
public DeckGenPool getCardPool() {
return cardPool;
}

View File

@@ -4,9 +4,14 @@ import java.util.ArrayList;
import java.util.List;
import forge.assets.FSkinProp;
import forge.card.MagicColor;
import forge.planarconquest.ConquestPlane.Region;
import forge.util.Aggregates;
import forge.util.FCollectionView;
public class ConquestPlaneMap {
private static final double sqrt3 = (float)Math.sqrt(3);
//use 2 dimensional array to represent tile grid
private final int gridSize;
private final HexagonTile[][] grid;
@@ -14,13 +19,13 @@ public class ConquestPlaneMap {
private int tileWidth, tileHeight, padding;
public ConquestPlaneMap(ConquestPlane plane) {
int size = (int)Math.round(Math.sqrt(plane.getCardPool().size() / 3)); //use card pool size to determine grid size
int size = (int)Math.round(Math.sqrt(plane.getCardPool().size() / 2)); //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();
generateRandomGrid(plane);
}
public void setTileWidth(int tileWidth0) {
@@ -96,48 +101,44 @@ public class ConquestPlaneMap {
void draw(HexagonTile tile, int x, int y, int w, int h);
}
private void generateRandomGrid() {
int startQ = gridSize / 2; //player will start at center of grid always
int startR = startQ;
int colorIndex = 0; //TODO: Determine initial color index from planeswalker
addTile(startQ, startR, colorIndex);
private void generateRandomGrid(ConquestPlane plane) {
int center = gridSize / 2; //player will start at center of grid always
addTile(center, center, null);
int max = gridSize - 1;
int minCount = Math.round(gridSize * gridSize * 0.75f); //ensure at least 75% 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, colorIndex)) {
//alternate which coordinate is incremented as we move towards center
if (tileCount % 2 == 0 && r != startR) {
if (r > startR) {
r--;
//divide the grid into regions
FCollectionView<Region> regions = plane.getRegions();
int regionCount = regions.size();
double regionAngle = 2 * Math.PI / regionCount;
//these assume a tile width of 2, radius of 1
double centerX = 1.5 * center;
double centerY = sqrt3 * (center + 0.5f * (center & 1));
double maxDist = (centerX + centerY) / 2;
//create a circular map, divided into regions
for (int q = 0; q < gridSize; q++) {
for (int r = 0; r < gridSize; r++) {
double x = 1.5 * q;
double y = sqrt3 * (r + 0.5f * (q & 1));
double dx = x - centerX;
double dy = y - centerY;
double dist = Math.sqrt(dx * dx + dy * dy);
if (dist > maxDist) {
continue;
}
else {
r++;
double angle = Math.atan2(dy, dx) + Math.PI;
int regionIndex = (int)Math.floor(angle / regionAngle);
if (regionIndex >= regionCount) {
regionIndex = 0;
}
addTile(q, r, regions.get(regionIndex));
}
else if (q > startQ) {
q--;
}
else if (q < startQ) {
q++;
}
else if (r > startR) {
r--;
}
else {
r++;
}
}
colorIndex = Aggregates.randomInt(0, 4); //pick a random color for the next set of tiles
}
}
private boolean addTile(int q, int r, int colorIndex) {
private boolean addTile(int q, int r, Region region) {
if (grid[q][r] == null) {
grid[q][r] = new HexagonTile(q, r, colorIndex);
grid[q][r] = new HexagonTile(q, r, region);
tileCount++;
return true;
}
@@ -146,12 +147,39 @@ public class ConquestPlaneMap {
public class HexagonTile {
private final int q, r;
private final Region region;
private final int colorIndex;
private HexagonTile(int q0, int r0, int colorIndex0) {
private HexagonTile(int q0, int r0, Region region0) {
q = q0;
r = r0;
colorIndex = colorIndex0;
region = region0;
if (region == null) {
colorIndex = 0;
}
else if (region.getColorSet().isColorless()) {
colorIndex = 0;
}
else if (region.getColorSet().isMonoColor()) {
int index;
byte color = region.getColorSet().getColor();
for (index = 0; index < 5; index++) {
if (MagicColor.WUBRG[index] == color) {
break;
}
}
colorIndex = index;
}
else { //for multicolor regions, choose one of the colors at random
int index;
while (true) {
index = Aggregates.randomInt(0, 4);
if (region.getColorSet().hasAnyColor(MagicColor.WUBRG[index])) {
break;
}
}
colorIndex = index;
}
}
public int getColorIndex() {