Implemented Seven Dwarves

This commit is contained in:
Evan Kranzler 2019-09-14 19:07:41 -04:00
parent 3491b36ae8
commit a03e5f11fb
11 changed files with 104 additions and 68 deletions

View file

@ -133,14 +133,7 @@ public class AusHighlander extends Constructed {
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
int totalPoints = 0;
for (Map.Entry<String, Integer> entry : counts.entrySet()) {

View file

@ -49,14 +49,7 @@ public class Brawl extends Constructed {
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
for (String bannedCard : banned) {
if (counts.containsKey(bannedCard)) {

View file

@ -88,14 +88,7 @@ public class CanadianHighlander extends Constructed {
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
int allowedPoints = 10;
int totalPoints = 0;

View file

@ -99,14 +99,7 @@ public class Commander extends Constructed {
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
for (String bannedCard : banned) {
if (counts.containsKey(bannedCard)) {

View file

@ -59,14 +59,7 @@ public class FreeformCommander extends Constructed {
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
if (deck.getSideboard().isEmpty() || deck.getSideboard().size() > 2) {
invalid.put("Commander", "Sideboard must contain only the commander(s)");

View file

@ -99,14 +99,7 @@ public class Oathbreaker extends Vintage {
}
}
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
Set<String> commanderNames = new HashSet<>();
Set<String> signatureSpells = new HashSet<>();

View file

@ -113,14 +113,7 @@ public class TinyLeaders extends Constructed {
counts.put(deck.getName(), 1); // add the commander to the counts, so it can't be in the deck or sideboard again
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 1) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(1, counts) && valid;
for (String bannedCard : banned) {
if (counts.containsKey(bannedCard)) {

View file

@ -3,6 +3,9 @@ package mage.deck;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckValidator;
import java.util.HashMap;
import java.util.Map;
/**
* @author BetaSteward_at_googlemail.com
*/
@ -29,9 +32,15 @@ public class Limited extends DeckValidator {
if (deck.getCards().size() < getDeckMinSize()) {
invalid.put("Deck", "Must contain at least " + getDeckMinSize() + " cards: has only " + deck.getCards().size() + " cards");
valid = false;
}
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
return valid;
}
}

View file

@ -0,0 +1,64 @@
package mage.cards.s;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class SevenDwarves extends CardImpl {
private static final FilterPermanent filter = new FilterControlledCreaturePermanent();
static {
filter.add(AnotherPredicate.instance);
filter.add(new NamePredicate("Seven Dwarves"));
}
private static final DynamicValue xValue = new PermanentsOnBattlefieldCount(filter);
public SevenDwarves(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.subtype.add(SubType.DWARF);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Seven Dwarves gets +1/+1 for each other creature named Seven Dwarves you control.
this.addAbility(new SimpleStaticAbility(
new BoostSourceEffect(xValue, xValue, Duration.WhileOnBattlefield).setText(
"{this} gets +1/+1 for each other creature named Seven Dwarves you control"
)
));
// A deck can have up to seven cards named Seven Dwarves.
this.addAbility(new SimpleStaticAbility(
Zone.ALL, new InfoEffect("A deck can have up to seven cards named Seven Dwarves.")
));
}
private SevenDwarves(final SevenDwarves card) {
super(card);
}
@Override
public SevenDwarves copy() {
return new SevenDwarves(this);
}
}

View file

@ -155,6 +155,7 @@ public final class ThroneOfEldraine extends ExpansionSet {
cards.add(new SetCardInfo("Savvy Hunter", 200, Rarity.UNCOMMON, mage.cards.s.SavvyHunter.class));
cards.add(new SetCardInfo("Scorching Dragonfire", 139, Rarity.COMMON, mage.cards.s.ScorchingDragonfire.class));
cards.add(new SetCardInfo("Searing Barrage", 140, Rarity.COMMON, mage.cards.s.SearingBarrage.class));
cards.add(new SetCardInfo("Seven Dwarves", 141, Rarity.COMMON, mage.cards.s.SevenDwarves.class));
cards.add(new SetCardInfo("Shimmer Dragon", 317, Rarity.RARE, mage.cards.s.ShimmerDragon.class));
cards.add(new SetCardInfo("Shinechaser", 201, Rarity.UNCOMMON, mage.cards.s.Shinechaser.class));
cards.add(new SetCardInfo("Shining Armor", 29, Rarity.COMMON, mage.cards.s.ShiningArmor.class));

View file

@ -16,8 +16,8 @@ public class Constructed extends DeckValidator {
private static final Logger logger = Logger.getLogger(DeckValidator.class);
protected static final List<String> anyNumberCardsAllowed = new ArrayList<>(Arrays.asList(
"Relentless Rats", "Shadowborn Apostle", "Rat Colony", "Persistent Petitioners"
private static final List<String> anyNumberCardsAllowed = new ArrayList<>(Arrays.asList(
"Relentless Rats", "Shadowborn Apostle", "Rat Colony", "Persistent Petitioners", "Seven Dwarves"
));
protected static final List<String> basicLandNames = new ArrayList<>(Arrays.asList(
"Forest", "Island", "Mountain", "Swamp", "Plains", "Wastes", "Snow-Covered Forest",
@ -67,14 +67,8 @@ public class Constructed extends DeckValidator {
Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards());
countCards(counts, deck.getSideboard());
for (Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 4) {
if (!basicLandNames.contains(entry.getKey()) && !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
}
valid = checkCounts(4, counts) && valid;
for (String bannedCard : banned) {
if (counts.containsKey(bannedCard)) {
invalid.put(bannedCard, "Banned");
@ -179,4 +173,21 @@ public class Constructed extends DeckValidator {
}
return legal;
}
protected boolean checkCounts(int maxCopies, Map<String, Integer> counts) {
boolean valid = true;
for (Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > maxCopies
&& !basicLandNames.contains(entry.getKey())
&& !anyNumberCardsAllowed.contains(entry.getKey())) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) {
invalid.put(entry.getKey(), "Too many: " + entry.getValue());
valid = false;
}
}
return valid;
}
}