mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Support laying out panels in region display
This commit is contained in:
@@ -7,11 +7,11 @@ public enum ConquestAction {
|
||||
AttackNE(FSkinProp.IMG_ATTACK),
|
||||
AttackE(FSkinProp.IMG_ATTACK),
|
||||
Defend(FSkinProp.IMG_DEFEND),
|
||||
Recruit(FSkinProp.IMG_ATTACK),
|
||||
Study(FSkinProp.ICO_QUEST_ZEP),
|
||||
Recruit(FSkinProp.IMG_PHASING),
|
||||
Study(FSkinProp.IMG_COSTRESERVED),
|
||||
Deploy(FSkinProp.IMG_SUMMONSICK),
|
||||
ReturnToBase(FSkinProp.ICO_QUEST_ZEP),
|
||||
Travel(FSkinProp.ICO_QUEST_ZEP);
|
||||
ReturnToBase(FSkinProp.IMG_SUMMONSICK),
|
||||
Travel(FSkinProp.IMG_SUMMONSICK);
|
||||
|
||||
private final FSkinProp icon;
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ public class ConquestCommander {
|
||||
|
||||
private ConquestAction currentDayAction;
|
||||
|
||||
public ConquestCommander(PaperCard card0, DeckGenPool cardPool0) {
|
||||
public ConquestCommander(PaperCard card0, DeckGenPool cardPool0, boolean forAi) {
|
||||
card = card0;
|
||||
deck = ConquestUtil.generateHumanDeck(card0, cardPool0);
|
||||
deck = ConquestUtil.generateDeck(card0, cardPool0, forAi);
|
||||
}
|
||||
|
||||
public PaperCard getCard() {
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class ConquestData {
|
||||
}
|
||||
|
||||
private void addCommander(PaperCard card) {
|
||||
ConquestCommander commander = new ConquestCommander(card, currentPlane.getCardPool());
|
||||
ConquestCommander commander = new ConquestCommander(card, currentPlane.getCardPool(), false);
|
||||
getCurrentPlaneData().getCommanders().add(commander);
|
||||
decks.put(commander.getDeck().getName(), commander.getDeck());
|
||||
collection.addAll(commander.getDeck().getMain());
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
*/
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.GuiBase;
|
||||
@@ -30,6 +32,7 @@ import forge.card.MagicColor;
|
||||
import forge.deck.generation.DeckGenPool;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FCollection;
|
||||
import forge.util.FCollectionView;
|
||||
|
||||
@@ -279,13 +282,15 @@ public enum ConquestPlane {
|
||||
commanders.add(pc);
|
||||
}
|
||||
int count = 0;
|
||||
for (Region region : regions) {
|
||||
if (region.pred.apply(pc)) {
|
||||
region.cardPool.add(pc);
|
||||
if (isCommander) {
|
||||
region.commanders.add(pc);
|
||||
if (!type.isBasicLand()) { //add all basic lands to all regions below
|
||||
for (Region region : regions) {
|
||||
if (region.pred.apply(pc)) {
|
||||
region.cardPool.add(pc);
|
||||
if (isCommander) {
|
||||
region.commanders.add(pc);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
//if card doesn't match any region's predicate,
|
||||
@@ -384,6 +389,16 @@ public enum ConquestPlane {
|
||||
return commanders;
|
||||
}
|
||||
|
||||
public ConquestCommander getRandomOpponent(ConquestCommander[] used) {
|
||||
HashSet<PaperCard> cards = new HashSet<PaperCard>(commanders);
|
||||
for (int i = 0; i < used.length; i++) {
|
||||
if (used[i] != null) {
|
||||
cards.remove(used[i]);
|
||||
}
|
||||
}
|
||||
return new ConquestCommander(Aggregates.random(cards), cardPool, true);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
|
||||
public class ConquestPlaneData {
|
||||
private final List<ConquestCommander> commanders = new ArrayList<ConquestCommander>();
|
||||
private final Map<Region, RegionData> regionDataLookup = new HashMap<Region, RegionData>();
|
||||
|
||||
private int wins, losses;
|
||||
|
||||
@@ -27,4 +32,34 @@ public class ConquestPlaneData {
|
||||
public int getLosses() {
|
||||
return losses;
|
||||
}
|
||||
|
||||
public RegionData getRegionData(Region region) {
|
||||
RegionData regionData = regionDataLookup.get(region);
|
||||
if (regionData == null) {
|
||||
regionData = new RegionData(region);
|
||||
regionDataLookup.put(region, regionData);
|
||||
}
|
||||
return regionData;
|
||||
}
|
||||
|
||||
public class RegionData {
|
||||
private final Region region;
|
||||
private final ConquestCommander[] commanders = new ConquestCommander[4];
|
||||
|
||||
private RegionData(Region region0) {
|
||||
region = region0;
|
||||
commanders[0] = region.getRandomOpponent(commanders);
|
||||
commanders[1] = region.getRandomOpponent(commanders);
|
||||
commanders[2] = region.getRandomOpponent(commanders);
|
||||
//leave commanders[3] open for deployed commander
|
||||
}
|
||||
|
||||
public Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public ConquestCommander getCommander(int index) {
|
||||
return commanders[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,13 @@ import forge.deck.generation.IDeckGenPool;
|
||||
import forge.item.PaperCard;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.quest.QuestUtil;
|
||||
import forge.util.Aggregates;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.gui.SOptionPane;
|
||||
|
||||
public class ConquestUtil {
|
||||
private ConquestUtil() {}
|
||||
|
||||
public static Deck generateHumanDeck(PaperCard commander, IDeckGenPool pool) {
|
||||
return generateDeck(commander, pool, false);
|
||||
}
|
||||
public static Deck generateAiDeck(Iterable<PaperCard> commanderOptions, IDeckGenPool pool) {
|
||||
return generateDeck(Aggregates.random(commanderOptions), pool, true);
|
||||
}
|
||||
private static Deck generateDeck(PaperCard commander, IDeckGenPool pool, boolean forAi) {
|
||||
public static Deck generateDeck(PaperCard commander, IDeckGenPool pool, boolean forAi) {
|
||||
ColorSet colorID = commander.getRules().getColorIdentity();
|
||||
|
||||
List<String> colors = new ArrayList<String>();
|
||||
|
||||
Reference in New Issue
Block a user