mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Support rendering path through regions based on opponents
This commit is contained in:
@@ -47,12 +47,12 @@ public class ConquestDataIO {
|
||||
/*ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Kamigawa,
|
||||
ConquestPlane.Kamigawa.getCardPool().getCard("Meloku the Clouded Mirror"));*/
|
||||
ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Mirrodin,
|
||||
ConquestPlane.Mirrodin.getCardPool().getCard("Glissa Sunseeker"));
|
||||
/*ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Mirrodin,
|
||||
ConquestPlane.Mirrodin.getCardPool().getCard("Glissa Sunseeker"));*/
|
||||
ConquestData temp = new ConquestData("My Conquest", 0,
|
||||
ConquestPlane.Ravnica,
|
||||
ConquestPlane.Ravnica.getCardPool().getCard("Savra, Queen of the Golgari"));*/
|
||||
ConquestPlane.Ravnica.getCardPool().getCard("Savra, Queen of the Golgari"));
|
||||
return temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.item.PaperCard;
|
||||
import forge.planarconquest.ConquestPlane.Region;
|
||||
|
||||
public class ConquestOpponent {
|
||||
private final PaperCard commander;
|
||||
private final Region region;
|
||||
private final ISkinImage mapIcon;
|
||||
|
||||
public ConquestOpponent(PaperCard commander0, Region region0) {
|
||||
commander = commander0;
|
||||
region = region0;
|
||||
mapIcon = GuiBase.getInterface().getSkinIcon(determineMapIcon());
|
||||
}
|
||||
|
||||
//determine map icon from commander color set
|
||||
private FSkinProp determineMapIcon() {
|
||||
ColorSet colors = commander.getRules().getColorIdentity();
|
||||
switch (colors.countColors()) {
|
||||
case 0:
|
||||
return FSkinProp.IMG_MANA_COLORLESS;
|
||||
case 1:
|
||||
switch (colors.getColor()) {
|
||||
case MagicColor.WHITE:
|
||||
return FSkinProp.IMG_MANA_W;
|
||||
case MagicColor.BLUE:
|
||||
return FSkinProp.IMG_MANA_U;
|
||||
case MagicColor.BLACK:
|
||||
return FSkinProp.IMG_MANA_B;
|
||||
case MagicColor.RED:
|
||||
return FSkinProp.IMG_MANA_R;
|
||||
default:
|
||||
return FSkinProp.IMG_MANA_G;
|
||||
}
|
||||
case 2:
|
||||
switch (colors.getColor()) {
|
||||
case MagicColor.WHITE | MagicColor.BLUE:
|
||||
return FSkinProp.IMG_MANA_HYBRID_WU;
|
||||
case MagicColor.BLUE | MagicColor.BLACK:
|
||||
return FSkinProp.IMG_MANA_HYBRID_UB;
|
||||
case MagicColor.BLACK | MagicColor.RED:
|
||||
return FSkinProp.IMG_MANA_HYBRID_BR;
|
||||
case MagicColor.RED | MagicColor.GREEN:
|
||||
return FSkinProp.IMG_MANA_HYBRID_RG;
|
||||
case MagicColor.GREEN | MagicColor.WHITE:
|
||||
return FSkinProp.IMG_MANA_HYBRID_GW;
|
||||
case MagicColor.WHITE | MagicColor.BLACK:
|
||||
return FSkinProp.IMG_MANA_HYBRID_WB;
|
||||
case MagicColor.BLUE | MagicColor.RED:
|
||||
return FSkinProp.IMG_MANA_HYBRID_UR;
|
||||
case MagicColor.BLACK | MagicColor.GREEN:
|
||||
return FSkinProp.IMG_MANA_HYBRID_BG;
|
||||
case MagicColor.RED | MagicColor.WHITE:
|
||||
return FSkinProp.IMG_MANA_HYBRID_RW;
|
||||
default:
|
||||
return FSkinProp.IMG_MANA_HYBRID_GU;
|
||||
}
|
||||
default:
|
||||
return FSkinProp.IMG_MULTI;
|
||||
}
|
||||
}
|
||||
|
||||
public ISkinImage getMapIcon() {
|
||||
return mapIcon;
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,7 @@
|
||||
package forge.planarconquest;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.ISkinImage;
|
||||
import forge.card.CardEdition;
|
||||
@@ -240,6 +237,9 @@ public enum ConquestPlane {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Region region : regions) {
|
||||
region.generateOpponents();
|
||||
}
|
||||
commanders.sort(); //sort main commanders list for the sake of UI
|
||||
}
|
||||
|
||||
@@ -277,6 +277,7 @@ public enum ConquestPlane {
|
||||
private final ColorSet colorSet;
|
||||
private final Predicate<PaperCard> pred;
|
||||
private final DeckGenPool cardPool = new DeckGenPool();
|
||||
private final FCollection<ConquestOpponent> opponents = new FCollection<ConquestOpponent>();
|
||||
private final FCollection<PaperCard> commanders = new FCollection<PaperCard>();
|
||||
|
||||
private ISkinImage art;
|
||||
@@ -318,24 +319,39 @@ public enum ConquestPlane {
|
||||
return cardPool;
|
||||
}
|
||||
|
||||
public FCollectionView<PaperCard> getCommanders() {
|
||||
return commanders;
|
||||
public FCollectionView<ConquestOpponent> getOpponents() {
|
||||
return opponents;
|
||||
}
|
||||
|
||||
public ConquestCommander getRandomOpponent(ConquestCommander[] used) {
|
||||
//each region should have 15 opponents include one boss
|
||||
private void generateOpponents() {
|
||||
int opponentsBeforeBoss = 14;
|
||||
HashSet<PaperCard> cards = new HashSet<PaperCard>(commanders);
|
||||
for (int i = 0; i < used.length; i++) {
|
||||
if (used[i] != null) {
|
||||
cards.remove(used[i].getCard());
|
||||
if (cards.size() < opponentsBeforeBoss) {
|
||||
//if not enough commanders, add normal creatures as non-commander opponents
|
||||
Iterable<PaperCard> creatures = cardPool.getAllCards(new Predicate<PaperCard>() {
|
||||
@Override
|
||||
public boolean apply(PaperCard card) {
|
||||
return card.getRules().getType().isCreature();
|
||||
}
|
||||
});
|
||||
while (cards.size() < opponentsBeforeBoss) {
|
||||
PaperCard card = Aggregates.random(creatures);
|
||||
if (!cards.contains(card)) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cards.isEmpty()) { //if all commanders are used, we can't prevent duplicates
|
||||
cards.addAll(commanders);
|
||||
if (cards.isEmpty()) {
|
||||
Iterables.addAll(cards, FModel.getConquest().getModel().getCurrentPlane().getCommanders());
|
||||
else {
|
||||
while (cards.size() > opponentsBeforeBoss) {
|
||||
cards.remove(Aggregates.random(cards));
|
||||
}
|
||||
}
|
||||
return new ConquestCommander(Aggregates.random(cards), cardPool, true);
|
||||
for (PaperCard card : cards) {
|
||||
opponents.add(new ConquestOpponent(card, this));
|
||||
}
|
||||
//TODO: Determine boss
|
||||
opponents.add(new ConquestOpponent(FModel.getMagicDb().getCommonCards().getCard("Savra, Queen of the Golgari"), this));
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
Reference in New Issue
Block a user