Add 7 Dwarves

This commit is contained in:
tehdiplomat
2019-11-11 14:12:49 -05:00
parent 86d7069626
commit 02299a0400
5 changed files with 69 additions and 36 deletions

View File

@@ -21,7 +21,6 @@ import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import forge.StaticData; import forge.StaticData;
import forge.card.CardRules; import forge.card.CardRules;
import forge.card.CardRulesPredicates; import forge.card.CardRulesPredicates;
@@ -37,8 +36,11 @@ import forge.util.TextUtil;
import org.apache.commons.lang3.Range; import org.apache.commons.lang3.Range;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
/** /**
* GameType is an enum to determine the type of current game. :) * GameType is an enum to determine the type of current game. :)
@@ -324,23 +326,32 @@ public enum DeckFormat {
} }
final int maxCopies = getMaxCardCopies(); final int maxCopies = getMaxCardCopies();
if (maxCopies < Integer.MAX_VALUE) { //Must contain no more than 4 of the same card
//Must contain no more than 4 of the same card //shared among the main deck and sideboard, except
//shared among the main deck and sideboard, except //basic lands, Shadowborn Apostle, Relentless Rats and Rat Colony
//basic lands, Shadowborn Apostle, Relentless Rats and Rat Colony // Seven Dwarves can have 7 in the deck. More than 7 in deck + sb is ok in Limited
final CardPool allCards = deck.getAllCardsInASinglePool(hasCommander()); final CardPool allCards = deck.getAllCardsInASinglePool(hasCommander());
// should group all cards by name, so that different editions of same card are really counted as the same card // should group all cards by name, so that different editions of same card are really counted as the same card
for (final Entry<String, Integer> cp : Aggregates.groupSumBy(allCards, PaperCard.FN_GET_NAME)) { for (final Entry<String, Integer> cp : Aggregates.groupSumBy(allCards, PaperCard.FN_GET_NAME)) {
final IPaperCard simpleCard = StaticData.instance().getCommonCards().getCard(cp.getKey()); final IPaperCard simpleCard = StaticData.instance().getCommonCards().getCard(cp.getKey());
if (simpleCard == null) { // Might cause issues since it ignores "Special" Cards
return TextUtil.concatWithSpace("contains the nonexisting card", cp.getKey()); if (simpleCard == null) {
} return TextUtil.concatWithSpace("contains the nonexisting card", cp.getKey());
}
if (!canHaveAnyNumberOf(simpleCard) && cp.getValue() > maxCopies) { if (canHaveAnyNumberOf(simpleCard)) {
return TextUtil.concatWithSpace("must not contain more than", String.valueOf(maxCopies), "copies of the card", cp.getKey()); continue;
} }
Integer cardCopies = canHaveSpecificNumberInDeck(simpleCard);
if (cardCopies != null && deck.getMain().countByName(cp.getKey(), true) > cardCopies) {
return TextUtil.concatWithSpace("must not contain more than", String.valueOf(cardCopies), "copies of the card", cp.getKey());
}
if (cardCopies == null && cp.getValue() > maxCopies) {
return TextUtil.concatWithSpace("must not contain more than", String.valueOf(maxCopies), "copies of the card", cp.getKey());
} }
} }
@@ -362,6 +373,16 @@ public enum DeckFormat {
"A deck can have any number of cards named CARDNAME."); "A deck can have any number of cards named CARDNAME.");
} }
public static Integer canHaveSpecificNumberInDeck(final IPaperCard card) {
// Ideally, this would be parsed during card parsing and set this value
if (Iterables.contains(card.getRules().getMainPart().getKeywords(),
"A deck can have up to seven cards named CARDNAME.")) {
return 7;
}
return null;
}
public static String getPlaneSectionConformanceProblem(final CardPool planes) { public static String getPlaneSectionConformanceProblem(final CardPool planes) {
//Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton. //Must contain at least 10 planes/phenomenons, but max 2 phenomenons. Singleton.
if (planes == null || planes.countAll() < 10) { if (planes == null || planes.countAll() < 10) {

View File

@@ -212,6 +212,12 @@ public abstract class ACEditorBase<TItem extends InventoryItem, TModel extends D
} }
else { else {
max = (limit == CardLimit.Singleton ? 1 : FModel.getPreferences().getPrefInt(FPref.DECK_DEFAULT_CARD_LIMIT)); max = (limit == CardLimit.Singleton ? 1 : FModel.getPreferences().getPrefInt(FPref.DECK_DEFAULT_CARD_LIMIT));
Integer cardCopies = DeckFormat.canHaveSpecificNumberInDeck(card);
if (cardCopies != null) {
max = cardCopies;
}
Entry<String, Integer> cardAmountInfo = Iterables.find(cardsByName, new Predicate<Entry<String, Integer>>() { Entry<String, Integer> cardAmountInfo = Iterables.find(cardsByName, new Predicate<Entry<String, Integer>>() {
@Override @Override
public boolean apply(Entry<String, Integer> t) { public boolean apply(Entry<String, Integer> t) {

View File

@@ -10,11 +10,7 @@ import com.google.common.collect.ImmutableList;
import forge.Forge; import forge.Forge;
import forge.Forge.KeyInputAdapter; import forge.Forge.KeyInputAdapter;
import forge.Graphics; import forge.Graphics;
import forge.assets.FImage; import forge.assets.*;
import forge.assets.FSkin;
import forge.assets.FSkinFont;
import forge.assets.FSkinImage;
import forge.assets.FTextureRegionImage;
import forge.card.CardDb; import forge.card.CardDb;
import forge.card.CardEdition; import forge.card.CardEdition;
import forge.card.CardPreferences; import forge.card.CardPreferences;
@@ -37,26 +33,14 @@ import forge.planarconquest.ConquestUtil;
import forge.properties.ForgePreferences.FPref; import forge.properties.ForgePreferences.FPref;
import forge.screens.FScreen; import forge.screens.FScreen;
import forge.screens.TabPageScreen; import forge.screens.TabPageScreen;
import forge.toolbox.FContainer; import forge.toolbox.*;
import forge.toolbox.FEvent;
import forge.toolbox.FEvent.FEventHandler; import forge.toolbox.FEvent.FEventHandler;
import forge.toolbox.FEvent.FEventType; import forge.toolbox.FEvent.FEventType;
import forge.toolbox.FLabel; import forge.util.*;
import forge.toolbox.FOptionPane;
import forge.toolbox.GuiChoose;
import forge.util.Callback;
import forge.util.ItemPool;
import forge.util.Lang;
import forge.util.Localizer;
import forge.util.Utils;
import forge.util.storage.IStorage; import forge.util.storage.IStorage;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry; import java.util.Map.Entry;
public class FDeckEditor extends TabPageScreen<FDeckEditor> { public class FDeckEditor extends TabPageScreen<FDeckEditor> {
@@ -779,6 +763,12 @@ public class FDeckEditor extends TabPageScreen<FDeckEditor> {
} }
else { else {
max = (limit == CardLimit.Singleton ? 1 : FModel.getPreferences().getPrefInt(FPref.DECK_DEFAULT_CARD_LIMIT)); max = (limit == CardLimit.Singleton ? 1 : FModel.getPreferences().getPrefInt(FPref.DECK_DEFAULT_CARD_LIMIT));
Integer cardCopies = DeckFormat.canHaveSpecificNumberInDeck(card);
if (cardCopies != null) {
max = cardCopies;
}
max -= deck.getMain().count(card); max -= deck.getMain().count(card);
if (deck.has(DeckSection.Sideboard)) { if (deck.has(DeckSection.Sideboard)) {
max -= deck.get(DeckSection.Sideboard).count(card); max -= deck.get(DeckSection.Sideboard).count(card);

View File

@@ -0,0 +1,11 @@
Name:Seven Dwarves
ManaCost:1 R
Types:Creature Dwarf
PT:2/2
K:A deck can have up to seven cards named CARDNAME.
S:Mode$ Continuous | Affected$ Card.Self | AddPower$ X | AddToughness$ X | References$ X | Description$ CARDNAME gets +1/+1 for each other creature named Seven Dwarves you control.
SVar:X:Count$Valid Creature.namedSeven Dwarves+Other
SVar:BuffedBy:Creature.namedSeven Dwarves
SVar:PlayMain1:TRUE
DeckNeeds:Name$Seven Dwarves
Oracle:Seven Dwarves gets +1/+1 for each other creature named Seven Dwarves you control.\nA deck can have up to seven cards named Seven Dwarves.

View File

@@ -360,6 +360,11 @@ public class QuestSpellShop {
//If this card has an exception to the card limit, e.g.: Relentless Rats, get the quest preference //If this card has an exception to the card limit, e.g.: Relentless Rats, get the quest preference
if (DeckFormat.canHaveAnyNumberOf(card)) { if (DeckFormat.canHaveAnyNumberOf(card)) {
numToKeep = FModel.getQuestPreferences().getPrefInt(QPref.PLAYSET_ANY_NUMBER_SIZE); numToKeep = FModel.getQuestPreferences().getPrefInt(QPref.PLAYSET_ANY_NUMBER_SIZE);
} else {
Integer cardCopies = DeckFormat.canHaveSpecificNumberInDeck(card);
if (cardCopies != null) {
numToKeep = cardCopies;
}
} }
if (numToKeep < item.getValue()) { if (numToKeep < item.getValue()) {