mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
CardUtil File format
This commit is contained in:
@@ -37,13 +37,13 @@ import static forge.adventure.data.RewardData.generateAllCards;
|
||||
*/
|
||||
public class CardUtil {
|
||||
public static final class CardPredicate implements Predicate<PaperCard> {
|
||||
enum ColorType
|
||||
{
|
||||
enum ColorType {
|
||||
Any,
|
||||
Colorless,
|
||||
MultiColor,
|
||||
MonoColor
|
||||
}
|
||||
|
||||
private final List<CardRarity> rarities = new ArrayList<>();
|
||||
private final List<String> editions = new ArrayList<>();
|
||||
private final List<String> subType = new ArrayList<>();
|
||||
@@ -116,23 +116,19 @@ public class CardUtil {
|
||||
if (this.text != null && !this.text.matcher(card.getRules().getOracleText()).find())
|
||||
return !this.shouldBeEqual;
|
||||
|
||||
if(this.matchAllColors)
|
||||
{
|
||||
if(!card.getRules().getColor().hasAllColors(this.colors))
|
||||
{
|
||||
if (this.matchAllColors) {
|
||||
if (!card.getRules().getColor().hasAllColors(this.colors)) {
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.colors!= MagicColor.ALL_COLORS)
|
||||
{
|
||||
if(!card.getRules().getColor().hasNoColorsExcept(this.colors)||(this.colors != MagicColor.COLORLESS && card.getRules().getColor().isColorless()))
|
||||
if (this.colors != MagicColor.ALL_COLORS) {
|
||||
if (!card.getRules().getColor().hasNoColorsExcept(this.colors)
|
||||
|| (this.colors != MagicColor.COLORLESS && card.getRules().getColor().isColorless()))
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
if(colorType!=ColorType.Any)
|
||||
{
|
||||
switch (colorType)
|
||||
{
|
||||
if (colorType != ColorType.Any) {
|
||||
switch (colorType) {
|
||||
case Colorless:
|
||||
if (!card.getRules().getColor().isColorless())
|
||||
return !this.shouldBeEqual;
|
||||
@@ -147,13 +143,10 @@ public class CardUtil {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!this.type.isEmpty())
|
||||
{
|
||||
if (!this.type.isEmpty()) {
|
||||
boolean found = false;
|
||||
for(CardType.CoreType type:card.getRules().getType().getCoreTypes())
|
||||
{
|
||||
if(this.type.contains(type))
|
||||
{
|
||||
for (CardType.CoreType type : card.getRules().getType().getCoreTypes()) {
|
||||
if (this.type.contains(type)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -161,13 +154,10 @@ public class CardUtil {
|
||||
if (!found)
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
if(!this.superType.isEmpty())
|
||||
{
|
||||
if (!this.superType.isEmpty()) {
|
||||
boolean found = false;
|
||||
for(CardType.Supertype type:card.getRules().getType().getSupertypes())
|
||||
{
|
||||
if(this.superType.contains(type))
|
||||
{
|
||||
for (CardType.Supertype type : card.getRules().getType().getSupertypes()) {
|
||||
if (this.superType.contains(type)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -175,30 +165,21 @@ public class CardUtil {
|
||||
if (!found)
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
if(this.matchAllSubTypes)
|
||||
{
|
||||
if(!this.subType.isEmpty())
|
||||
{
|
||||
if (this.matchAllSubTypes) {
|
||||
if (!this.subType.isEmpty()) {
|
||||
if (this.subType.size() != Iterables.size(card.getRules().getType().getSubtypes()))
|
||||
return !this.shouldBeEqual;
|
||||
for(String subtype:card.getRules().getType().getSubtypes())
|
||||
{
|
||||
if(!this.subType.contains(subtype))
|
||||
{
|
||||
for (String subtype : card.getRules().getType().getSubtypes()) {
|
||||
if (!this.subType.contains(subtype)) {
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!this.subType.isEmpty())
|
||||
{
|
||||
} else {
|
||||
if (!this.subType.isEmpty()) {
|
||||
boolean found = false;
|
||||
for(String subtype:card.getRules().getType().getSubtypes())
|
||||
{
|
||||
if(this.subType.contains(subtype))
|
||||
{
|
||||
for (String subtype : card.getRules().getType().getSubtypes()) {
|
||||
if (this.subType.contains(subtype)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -208,13 +189,10 @@ public class CardUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.keyWords.isEmpty())
|
||||
{
|
||||
if (!this.keyWords.isEmpty()) {
|
||||
boolean found = false;
|
||||
for(String keyWord:this.keyWords)
|
||||
{
|
||||
if(card.getRules().hasKeyword(keyWord))
|
||||
{
|
||||
for (String keyWord : this.keyWords) {
|
||||
if (card.getRules().hasKeyword(keyWord)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -223,11 +201,9 @@ public class CardUtil {
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
|
||||
if(!this.deckNeeds.isEmpty())
|
||||
{
|
||||
if (!this.deckNeeds.isEmpty()) {
|
||||
boolean found = false;
|
||||
for(String need:this.deckNeeds)
|
||||
{
|
||||
for (String need : this.deckNeeds) {
|
||||
// FormatExpected: X$Y, where X is DeckHints.Type and Y is a string descriptor
|
||||
String[] parts = need.split("\\$");
|
||||
|
||||
@@ -246,9 +222,9 @@ public class CardUtil {
|
||||
return !this.shouldBeEqual;
|
||||
}
|
||||
|
||||
|
||||
return this.shouldBeEqual;
|
||||
}
|
||||
|
||||
private Pattern getPattern(RewardData type) {
|
||||
if (type.cardText == null || type.cardText.isEmpty())
|
||||
return null;
|
||||
@@ -259,6 +235,7 @@ public class CardUtil {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public CardPredicate(final RewardData type, final boolean wantEqual) {
|
||||
this.matchAllSubTypes = type.matchAllSubTypes;
|
||||
this.matchAllColors = type.matchAllColors;
|
||||
@@ -266,15 +243,11 @@ public class CardUtil {
|
||||
for (int i = 0; type.manaCosts != null && i < type.manaCosts.length; i++)
|
||||
manaCosts.add(type.manaCosts[i]);
|
||||
text = getPattern(type);
|
||||
if(type.colors==null||type.colors.length==0)
|
||||
{
|
||||
if (type.colors == null || type.colors.length == 0) {
|
||||
this.colors = MagicColor.ALL_COLORS;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.colors = 0;
|
||||
for(String color:type.colors)
|
||||
{
|
||||
for (String color : type.colors) {
|
||||
if ("colorID".equals(color))
|
||||
for (byte c : Current.player().getColorIdentity())
|
||||
colors |= c;
|
||||
@@ -282,83 +255,69 @@ public class CardUtil {
|
||||
colors |= MagicColor.fromName(color.toLowerCase());
|
||||
}
|
||||
}
|
||||
if(type.keyWords!=null&&type.keyWords.length!=0)
|
||||
{
|
||||
if (type.keyWords != null && type.keyWords.length != 0) {
|
||||
keyWords.addAll(Arrays.asList(type.keyWords));
|
||||
}
|
||||
if(type.rarity!=null&&type.rarity.length!=0)
|
||||
{
|
||||
for(String rarity:type.rarity)
|
||||
{
|
||||
if (type.rarity != null) {
|
||||
for (String rarity : type.rarity) {
|
||||
rarities.add(CardRarity.smartValueOf(rarity));
|
||||
}
|
||||
}
|
||||
|
||||
if(type.subTypes!=null&&type.subTypes.length!=0)
|
||||
{
|
||||
if (type.subTypes != null && type.subTypes.length != 0) {
|
||||
subType.addAll(Arrays.asList(type.subTypes));
|
||||
}
|
||||
if(type.editions!=null&&type.editions.length!=0)
|
||||
{
|
||||
if (type.editions != null && type.editions.length != 0) {
|
||||
editions.addAll(Arrays.asList(type.editions));
|
||||
}
|
||||
if(type.superTypes!=null&&type.superTypes.length!=0)
|
||||
{
|
||||
if (type.superTypes != null) {
|
||||
for (String string : type.superTypes)
|
||||
superType.add(CardType.Supertype.getEnum(string));
|
||||
}
|
||||
if(type.cardTypes!=null&&type.cardTypes.length!=0)
|
||||
{
|
||||
if (type.cardTypes != null) {
|
||||
for (String string : type.cardTypes)
|
||||
this.type.add(CardType.CoreType.getEnum(string));
|
||||
}
|
||||
if(type.colorType!=null&&!type.colorType.isEmpty())
|
||||
{
|
||||
if (type.colorType != null && !type.colorType.isEmpty()) {
|
||||
this.colorType = ColorType.valueOf(type.colorType);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.colorType = ColorType.Any;
|
||||
}
|
||||
if (type.deckNeeds != null && type.deckNeeds.length != 0) {
|
||||
deckNeeds.addAll(Arrays.asList(type.deckNeeds));
|
||||
}
|
||||
if(type.minDate!=null&&!type.minDate.isEmpty())
|
||||
{
|
||||
if (type.minDate != null && !type.minDate.isEmpty()) {
|
||||
this.minDate = type.minDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.minDate = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<PaperCard> getPredicateResult(Iterable<PaperCard> cards,final RewardData data)
|
||||
{
|
||||
public static List<PaperCard> getPredicateResult(Iterable<PaperCard> cards, final RewardData data) {
|
||||
List<PaperCard> result = new ArrayList<>();
|
||||
CardPredicate pre = new CardPredicate(data, true);
|
||||
|
||||
for (final PaperCard item : cards)
|
||||
{
|
||||
for (final PaperCard item : cards) {
|
||||
if (pre.test(item))
|
||||
result.add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<PaperCard> generateCards(Iterable<PaperCard> cards,final RewardData data, final int count, Random r)
|
||||
{
|
||||
public static List<PaperCard> generateCards(Iterable<PaperCard> cards, final RewardData data, final int count,
|
||||
Random r) {
|
||||
boolean allCardVariants = Config.instance().getSettingData().useAllCardVariants;
|
||||
|
||||
final List<PaperCard> result = new ArrayList<>();
|
||||
List<PaperCard> pool = getPredicateResult(cards, data);
|
||||
if (pool.size() > 0) {
|
||||
if (!pool.isEmpty()) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
PaperCard candidate = pool.get(r.nextInt(pool.size()));
|
||||
if (candidate != null) {
|
||||
if (allCardVariants) {
|
||||
PaperCard finalCandidate = CardUtil.getCardByName(candidate.getCardName()); // get a random set variant
|
||||
// Get a random set variant
|
||||
PaperCard finalCandidate = CardUtil.getCardByName(candidate.getCardName());
|
||||
result.add(finalCandidate);
|
||||
} else {
|
||||
result.add(candidate);
|
||||
@@ -368,28 +327,22 @@ public class CardUtil {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static int getCardPrice(PaperCard card)
|
||||
{
|
||||
|
||||
public static int getCardPrice(PaperCard card) {
|
||||
if (card == null)
|
||||
return 0;
|
||||
switch (card.getRarity())
|
||||
{
|
||||
case BasicLand:
|
||||
return 5;
|
||||
case Common:
|
||||
return 50;
|
||||
case Uncommon:
|
||||
return 150;
|
||||
case Rare:
|
||||
return 300;
|
||||
case MythicRare:
|
||||
return 500;
|
||||
default:
|
||||
return 600;
|
||||
|
||||
return switch (card.getRarity()) {
|
||||
case BasicLand -> 5;
|
||||
case Common -> 50;
|
||||
case Uncommon -> 150;
|
||||
case Rare -> 300;
|
||||
case MythicRare -> 500;
|
||||
default -> 600;
|
||||
};
|
||||
}
|
||||
}
|
||||
public static int getRewardPrice(Reward reward)
|
||||
{
|
||||
|
||||
public static int getRewardPrice(Reward reward) {
|
||||
PaperCard card = reward.getCard();
|
||||
if (card != null)
|
||||
return getCardPrice(card);
|
||||
@@ -401,50 +354,45 @@ public class CardUtil {
|
||||
return reward.getCount() * 500;
|
||||
if (reward.getType() == Reward.Type.Gold)
|
||||
return reward.getCount();
|
||||
/*if(reward.getType() == Reward.Type.CardPack)
|
||||
return reward.getDeck().get(DeckSection.Main).countAll()*70;*/
|
||||
/*
|
||||
* if(reward.getType() == Reward.Type.CardPack)
|
||||
* return reward.getDeck().get(DeckSection.Main).countAll()*70;
|
||||
*/
|
||||
// TODO: Heitor - Price by card count and type of boosterPack.
|
||||
|
||||
|
||||
return 1000;
|
||||
}
|
||||
|
||||
public static Deck generateDeck(GeneratedDeckData data, CardEdition starterEdition, boolean discourageDuplicates)
|
||||
{
|
||||
List<String> editionCodes = (starterEdition != null)?Arrays.asList(starterEdition.getCode(), starterEdition.getCode2()):Arrays.asList("JMP", "J22", "DMU", "BRO", "ONE", "MOM");
|
||||
public static Deck generateDeck(GeneratedDeckData data, CardEdition starterEdition, boolean discourageDuplicates) {
|
||||
List<String> editionCodes = (starterEdition != null)
|
||||
? Arrays.asList(starterEdition.getCode(), starterEdition.getCode2())
|
||||
: Arrays.asList("JMP", "J22", "DMU", "BRO", "ONE", "MOM");
|
||||
Deck deck = new Deck(data.name);
|
||||
if(data.mainDeck!=null)
|
||||
{
|
||||
if (data.mainDeck != null) {
|
||||
deck.getOrCreate(DeckSection.Main).addAllFlat(generateAllCards(Arrays.asList(data.mainDeck), true));
|
||||
if (data.sideBoard != null)
|
||||
deck.getOrCreate(DeckSection.Sideboard).addAllFlat(generateAllCards(Arrays.asList(data.sideBoard), true));
|
||||
deck.getOrCreate(DeckSection.Sideboard)
|
||||
.addAllFlat(generateAllCards(Arrays.asList(data.sideBoard), true));
|
||||
return deck;
|
||||
}
|
||||
if(data.jumpstartPacks!=null)
|
||||
{
|
||||
if (data.jumpstartPacks != null) {
|
||||
deck.getOrCreate(DeckSection.Main);
|
||||
|
||||
Map<String, List<PaperCard>> packCandidates = null;
|
||||
List<String> usedPackNames = new ArrayList<String>();
|
||||
|
||||
for(int i=0;i<data.jumpstartPacks.length;i++)
|
||||
{
|
||||
|
||||
for (int i = 0; i < data.jumpstartPacks.length; i++) {
|
||||
final byte targetColor = MagicColor.fromName(data.jumpstartPacks[i]);
|
||||
String targetName;
|
||||
switch (targetColor)
|
||||
{
|
||||
default:
|
||||
case MagicColor.WHITE: targetName = "Plains"; break;
|
||||
case MagicColor.BLUE: targetName = "Island"; break;
|
||||
case MagicColor.BLACK: targetName = "Swamp"; break;
|
||||
case MagicColor.RED: targetName = "Mountain";break;
|
||||
case MagicColor.GREEN: targetName = "Forest"; break;
|
||||
}
|
||||
String targetName = switch (targetColor) {
|
||||
case MagicColor.BLUE -> "Island";
|
||||
case MagicColor.BLACK -> "Swamp";
|
||||
case MagicColor.RED -> "Mountain";
|
||||
case MagicColor.GREEN -> "Forest";
|
||||
default -> "Plains";
|
||||
};
|
||||
|
||||
packCandidates = new HashMap<>();
|
||||
for(SealedTemplate template : StaticData.instance().getSpecialBoosters())
|
||||
{
|
||||
for (SealedTemplate template : StaticData.instance().getSpecialBoosters()) {
|
||||
if (!editionCodes.contains(template.getEdition().split("\\s", 2)[0]))
|
||||
continue;
|
||||
List<PaperCard> packContents = new UnOpenedProduct(template).get();
|
||||
@@ -458,23 +406,23 @@ public class CardUtil {
|
||||
Map<String, List<PaperCard>> filteredPackCandidates = new HashMap<>();
|
||||
for (java.util.Map.Entry<String, List<PaperCard>> entry : packCandidates.entrySet()) {
|
||||
if (!usedPackNames.contains(entry.getKey())) {
|
||||
filteredPackCandidates.put(entry.getKey(), entry.getValue()); //deep copy so that packCandidates can be used if filtered ends up being empty
|
||||
// Deep copy so that packCandidates can be used if filtered ends up being empty
|
||||
filteredPackCandidates.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
// Only re-use a pack if all possibilities have already been chosen
|
||||
if (filteredPackCandidates.size() == 0)
|
||||
if (filteredPackCandidates.isEmpty())
|
||||
filteredPackCandidates = packCandidates;
|
||||
Object[] keys = filteredPackCandidates.keySet().toArray();
|
||||
|
||||
String keyName = (String) keys[Current.world().getRandom().nextInt(keys.length)];
|
||||
usedPackNames.add(keyName);
|
||||
selectedPack = filteredPackCandidates.remove(keyName);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
Object[] keys = packCandidates.keySet().toArray();
|
||||
selectedPack = packCandidates.get((String) keys[Current.world().getRandom().nextInt(keys.length)]);
|
||||
}
|
||||
//if the packContents size above is below 20, just get random card
|
||||
// If the packContents size above is below 20, add random cards
|
||||
int size = 20 - selectedPack.size();
|
||||
for (int c = 0; c < size; c++) {
|
||||
selectedPack.add(Aggregates.random(selectedPack));
|
||||
@@ -483,8 +431,7 @@ public class CardUtil {
|
||||
}
|
||||
return deck;
|
||||
}
|
||||
if(data.template!=null)
|
||||
{
|
||||
if (data.template != null) {
|
||||
float count = data.template.count;
|
||||
float lands = count * 0.4f;
|
||||
float spells = count - lands;
|
||||
@@ -577,6 +524,7 @@ public class CardUtil {
|
||||
|
||||
return cards;
|
||||
}
|
||||
|
||||
private static Collection<PaperCard> generateDualLands(List<String> landName, int count) {
|
||||
ArrayList<RewardData> rewards = new ArrayList<>();
|
||||
RewardData base = new RewardData();
|
||||
@@ -584,16 +532,11 @@ public class CardUtil {
|
||||
base.cardTypes = new String[] { "Land" };
|
||||
base.count = count;
|
||||
base.matchAllSubTypes = true;
|
||||
if(landName.size()==1)
|
||||
{
|
||||
if (landName.size() == 1) {
|
||||
base.subTypes = new String[] { landName.get(0) };
|
||||
}
|
||||
else if(landName.size()==2)
|
||||
{
|
||||
} else if (landName.size() == 2) {
|
||||
base.subTypes = new String[] { landName.get(0), landName.get(1) };
|
||||
}
|
||||
else if(landName.size()==3)
|
||||
{
|
||||
} else if (landName.size() == 3) {
|
||||
RewardData sub1 = new RewardData(base);
|
||||
RewardData sub2 = new RewardData(base);
|
||||
sub1.count /= 3;
|
||||
@@ -605,9 +548,7 @@ public class CardUtil {
|
||||
sub1.subTypes = new String[] { landName.get(1), landName.get(2) };
|
||||
sub2.subTypes = new String[] { landName.get(0), landName.get(2) };
|
||||
rewards.addAll(Arrays.asList(sub1, sub2));
|
||||
}
|
||||
else if(landName.size()==4)
|
||||
{
|
||||
} else if (landName.size() == 4) {
|
||||
RewardData sub1 = new RewardData(base);
|
||||
RewardData sub2 = new RewardData(base);
|
||||
RewardData sub3 = new RewardData(base);
|
||||
@@ -627,9 +568,7 @@ public class CardUtil {
|
||||
sub3.subTypes = new String[] { landName.get(1), landName.get(2) };
|
||||
sub4.subTypes = new String[] { landName.get(1), landName.get(3) };
|
||||
rewards.addAll(Arrays.asList(sub1, sub2, sub3, sub4));
|
||||
}
|
||||
else if(landName.size()==5)
|
||||
{
|
||||
} else if (landName.size() == 5) {
|
||||
RewardData sub1 = new RewardData(base);
|
||||
RewardData sub2 = new RewardData(base);
|
||||
RewardData sub3 = new RewardData(base);
|
||||
@@ -671,8 +610,7 @@ public class CardUtil {
|
||||
rewards.addAll(Arrays.asList(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9));
|
||||
}
|
||||
|
||||
Collection<PaperCard> ret = new ArrayList<>(generateAllCards(rewards, true));
|
||||
return ret;
|
||||
return new ArrayList<>(generateAllCards(rewards, true));
|
||||
}
|
||||
|
||||
private static Collection<PaperCard> generateLands(String landName, int count) {
|
||||
@@ -701,19 +639,21 @@ public class CardUtil {
|
||||
|
||||
private static List<RewardData> generateRewards(GeneratedDeckTemplateData template, float count, int[] manaCosts) {
|
||||
ArrayList<RewardData> ret = new ArrayList<>();
|
||||
ret.addAll(templateGenerate(template,count-(count*template.rares),manaCosts,new String[]{"Uncommon","Common"}));
|
||||
ret.addAll(templateGenerate(template,count*template.rares,manaCosts,new String[]{"Rare","Mythic Rare"}));
|
||||
ret.addAll(templateGenerate(template, count - (count * template.rares), manaCosts,
|
||||
new String[] { "Uncommon", "Common" }));
|
||||
ret.addAll(
|
||||
templateGenerate(template, count * template.rares, manaCosts, new String[] { "Rare", "Mythic Rare" }));
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static ArrayList<RewardData> templateGenerate(GeneratedDeckTemplateData template, float count, int[] manaCosts, String[] strings) {
|
||||
private static ArrayList<RewardData> templateGenerate(GeneratedDeckTemplateData template, float count,
|
||||
int[] manaCosts, String[] strings) {
|
||||
ArrayList<RewardData> ret = new ArrayList<>();
|
||||
RewardData base = new RewardData();
|
||||
base.manaCosts = manaCosts;
|
||||
base.rarity = strings;
|
||||
base.colors = template.colors;
|
||||
if(template.tribe!=null&&!template.tribe.isEmpty())
|
||||
{
|
||||
if (template.tribe != null && !template.tribe.isEmpty()) {
|
||||
RewardData caresAbout = new RewardData(base);
|
||||
caresAbout.cardText = "\\b" + template.tribe + "\\b";
|
||||
caresAbout.count = Math.round(count * template.tribeSynergyCards);
|
||||
@@ -721,21 +661,20 @@ public class CardUtil {
|
||||
|
||||
base.subTypes = new String[] { template.tribe };
|
||||
base.count = Math.round(count * (1 - template.tribeSynergyCards));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
base.count = Math.round(count);
|
||||
}
|
||||
ret.add(base);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme, boolean useGeneticAI) {
|
||||
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme,
|
||||
boolean useGeneticAI) {
|
||||
return getDeck(path, forAI, isFantasyMode, colors, isTheme, useGeneticAI, null, true);
|
||||
}
|
||||
|
||||
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme, boolean useGeneticAI, CardEdition starterEdition, boolean discourageDuplicates)
|
||||
{
|
||||
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme,
|
||||
boolean useGeneticAI, CardEdition starterEdition, boolean discourageDuplicates) {
|
||||
if (path.endsWith(".dck")) {
|
||||
FileHandle fileHandle = Config.instance().getFile(path);
|
||||
Deck deck = null;
|
||||
@@ -750,9 +689,7 @@ public class CardUtil {
|
||||
}
|
||||
|
||||
if (forAI && (isFantasyMode || useGeneticAI)) {
|
||||
Deck deck = DeckgenUtil.getRandomOrPreconOrThemeDeck(colors, forAI, isTheme, useGeneticAI);
|
||||
if (deck != null)
|
||||
return deck;
|
||||
return DeckgenUtil.getRandomOrPreconOrThemeDeck(colors, forAI, isTheme, useGeneticAI);
|
||||
}
|
||||
|
||||
Json json = new Json();
|
||||
@@ -766,23 +703,23 @@ public class CardUtil {
|
||||
|
||||
private static final GameFormat.Collection formats = FModel.getFormats();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private static final Predicate<CardEdition> filterPioneer = formats.getPioneer().editionLegalPredicate;
|
||||
private static final Predicate<CardEdition> filterModern = formats.getModern().editionLegalPredicate;
|
||||
private static final Predicate<CardEdition> filterVintage = formats.getVintage().editionLegalPredicate;
|
||||
private static final Predicate<CardEdition> filterStandard = formats.getStandard().editionLegalPredicate;
|
||||
|
||||
public static Deck generateStandardBoosterAsDeck() {
|
||||
return generateRandomBoosterPackAsDeck(filterStandard);
|
||||
}
|
||||
|
||||
public static Deck generatePioneerBoosterAsDeck() {
|
||||
return generateRandomBoosterPackAsDeck(filterPioneer);
|
||||
}
|
||||
|
||||
public static Deck generateModernBoosterAsDeck() {
|
||||
return generateRandomBoosterPackAsDeck(filterModern);
|
||||
}
|
||||
|
||||
public static Deck generateVintageBoosterAsDeck() {
|
||||
return generateRandomBoosterPackAsDeck(filterVintage);
|
||||
}
|
||||
@@ -854,7 +791,9 @@ public class CardUtil {
|
||||
.filter(input -> input.getEdition().equals(edition)).collect(Collectors.toList());
|
||||
|
||||
if (validCards.isEmpty()) {
|
||||
System.err.println("Unexpected behavior: tried to call getCardByNameAndEdition for card " + cardName + " from the edition " + edition + ", but didn't find it in the DB. A random existing instance will be returned if found.");
|
||||
System.err.println("Unexpected behavior: tried to call getCardByNameAndEdition for card " + cardName
|
||||
+ " from the edition " + edition
|
||||
+ ", but didn't find it in the DB. A random existing instance will be returned if found.");
|
||||
return getCardByName(cardName);
|
||||
}
|
||||
|
||||
@@ -862,7 +801,8 @@ public class CardUtil {
|
||||
}
|
||||
|
||||
public static Collection<PaperCard> getFullCardPool(boolean allCardVariants) {
|
||||
return allCardVariants ? FModel.getMagicDb().getCommonCards().getAllCards() : FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt();
|
||||
return allCardVariants
|
||||
? FModel.getMagicDb().getCommonCards().getAllCards()
|
||||
: FModel.getMagicDb().getCommonCards().getUniqueCardsNoAlt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user