mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
*Made the Generate option for planar decks actually generate a planar deck and not a scheme deck!
This commit is contained in:
@@ -338,4 +338,20 @@ public final class CardType implements Comparable<CardType> {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns wether or not this card is a Plane.
|
||||||
|
* @return a boolean
|
||||||
|
*/
|
||||||
|
public boolean isPlane() {
|
||||||
|
return this.coreType.contains(CardCoreType.Plane);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns wether or not this card is a Phenomenon.
|
||||||
|
* @return a boolean
|
||||||
|
*/
|
||||||
|
public boolean isPhenomenon() {
|
||||||
|
return this.coreType.contains(CardCoreType.Phenomenon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import forge.quest.QuestEvent;
|
|||||||
import forge.quest.QuestEventManager;
|
import forge.quest.QuestEventManager;
|
||||||
import forge.util.Aggregates;
|
import forge.util.Aggregates;
|
||||||
import forge.util.IStorage;
|
import forge.util.IStorage;
|
||||||
|
import forge.util.MyRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility collection for various types of decks.
|
* Utility collection for various types of decks.
|
||||||
@@ -331,4 +332,39 @@ public class DeckgenUtil {
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Deck generatePlanarDeck() {
|
||||||
|
Deck res = new Deck();
|
||||||
|
List<CardPrinted> allPlanars = new ArrayList<CardPrinted>();
|
||||||
|
for (CardPrinted c : CardDb.instance().getAllNonTraditionalCards()) {
|
||||||
|
if (c.getCard().getType().isPlane() || c.getCard().getType().isPhenomenon()) {
|
||||||
|
allPlanars.add(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int phenoms = 0;
|
||||||
|
int targetsize = MyRandom.getRandom().nextInt(allPlanars.size()-10)+10;
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
CardPrinted rndPlane = Aggregates.random(allPlanars);
|
||||||
|
allPlanars.remove(rndPlane);
|
||||||
|
|
||||||
|
if(rndPlane.getCard().getType().isPhenomenon() && phenoms < 2)
|
||||||
|
{
|
||||||
|
res.getSideboard().add(rndPlane);
|
||||||
|
phenoms++;
|
||||||
|
}
|
||||||
|
else if (rndPlane.getCard().getType().isPlane())
|
||||||
|
{
|
||||||
|
res.getSideboard().add(rndPlane);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(allPlanars.isEmpty() || res.getSideboard().countAll() == targetsize)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import forge.gui.toolbox.FDeckChooser;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.properties.ForgePreferences;
|
import forge.properties.ForgePreferences;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
|
import forge.util.Aggregates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls the constructed submenu in the home UI.
|
* Controls the constructed submenu in the home UI.
|
||||||
@@ -164,12 +165,19 @@ public enum CSubmenuPlanechase implements ICDoc {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
String sel = (String) obj;
|
String sel = (String) obj;
|
||||||
if (sel.equals("Random")) {
|
if (sel.equals("Random")) {
|
||||||
|
if (view.getAllPlanarDecks().isEmpty()) {
|
||||||
planes = Iterables.get(view.getAllPlanarDecks(), rnd.nextInt(Iterables.size(view.getAllPlanarDecks()))).getSideboard().toFlatList();
|
//Generate if no constructed scheme decks are available
|
||||||
|
System.out.println("Generating planar deck - no others available");
|
||||||
|
planes = DeckgenUtil.generatePlanarDeck().getSideboard().toFlatList();
|
||||||
|
} else {
|
||||||
|
System.out.println("Using planar deck: " + Aggregates.random(view.getAllPlanarDecks()).getName());
|
||||||
|
planes = Aggregates.random(view.getAllPlanarDecks()).getSideboard().toFlatList();
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//Generate
|
//Generate
|
||||||
planes = DeckgenUtil.generateSchemeDeck().getSideboard().toFlatList();
|
planes = DeckgenUtil.generatePlanarDeck().getSideboard().toFlatList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
planes = ((Deck) obj).getSideboard().toFlatList();
|
planes = ((Deck) obj).getSideboard().toFlatList();
|
||||||
|
|||||||
Reference in New Issue
Block a user