[LTR] Implement Nazgul

This commit is contained in:
theelk801 2023-05-30 18:24:54 -04:00
parent 75d1bdf71c
commit 82073bba73
5 changed files with 122 additions and 16 deletions

View file

@ -38,7 +38,7 @@ public class Limited extends DeckValidator {
Map<String, Integer> counts = new HashMap<>(); Map<String, Integer> counts = new HashMap<>();
countCards(counts, deck.getCards()); countCards(counts, deck.getCards());
for (Map.Entry<String, Integer> entry : counts.entrySet()) { for (Map.Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) { if (entry.getValue() > getMaxCopies(entry.getKey(), Integer.MAX_VALUE)) {
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true); addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
valid = false; valid = false;
} }

View file

@ -0,0 +1,89 @@
package mage.cards.n;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.counter.AddCountersAllEffect;
import mage.abilities.effects.keyword.TheRingTemptsYouEffect;
import mage.abilities.keyword.DeathtouchAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class Nazgul extends CardImpl {
public Nazgul(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}");
this.subtype.add(SubType.WRAITH);
this.subtype.add(SubType.KNIGHT);
this.power = new MageInt(1);
this.toughness = new MageInt(2);
// Deathtouch
this.addAbility(DeathtouchAbility.getInstance());
// When Nazgul enters the battlefield, the Ring tempts you.
this.addAbility(new EntersBattlefieldTriggeredAbility(new TheRingTemptsYouEffect()));
// Whenever the Ring tempts you, put a +1/+1 counter on each Wraith you control.
this.addAbility(new NazgulTriggeredAbility());
// A deck can have up to nine cards named Nazgul.
this.addAbility(new SimpleStaticAbility(
Zone.ALL, new InfoEffect("a deck can have up to nine cards named Nazgul")
));
}
private Nazgul(final Nazgul card) {
super(card);
}
@Override
public Nazgul copy() {
return new Nazgul(this);
}
}
class NazgulTriggeredAbility extends TriggeredAbilityImpl {
private static final FilterPermanent filter = new FilterControlledPermanent(SubType.WRAITH);
NazgulTriggeredAbility() {
super(Zone.BATTLEFIELD, new AddCountersAllEffect(CounterType.P1P1.createInstance(), filter));
setTriggerPhrase("Whenever the Ring tempts you, ");
}
private NazgulTriggeredAbility(final NazgulTriggeredAbility ability) {
super(ability);
}
@Override
public NazgulTriggeredAbility copy() {
return new NazgulTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.TEMPTED_BY_RING;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return isControlledBy(event.getPlayerId());
}
}

View file

@ -31,6 +31,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
cards.add(new SetCardInfo("Lobelia Sackville-Baggins", 93, Rarity.RARE, mage.cards.l.LobeliaSackvilleBaggins.class)); cards.add(new SetCardInfo("Lobelia Sackville-Baggins", 93, Rarity.RARE, mage.cards.l.LobeliaSackvilleBaggins.class));
cards.add(new SetCardInfo("Mount Doom", 258, Rarity.MYTHIC, mage.cards.m.MountDoom.class)); cards.add(new SetCardInfo("Mount Doom", 258, Rarity.MYTHIC, mage.cards.m.MountDoom.class));
cards.add(new SetCardInfo("Mountain", 278, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Mountain", 278, Rarity.LAND, mage.cards.basiclands.Mountain.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Nazgul", 100, Rarity.UNCOMMON, mage.cards.n.Nazgul.class));
cards.add(new SetCardInfo("Plains", 272, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS)); cards.add(new SetCardInfo("Plains", 272, Rarity.LAND, mage.cards.basiclands.Plains.class, FULL_ART_BFZ_VARIOUS));
cards.add(new SetCardInfo("Reprieve", 26, Rarity.UNCOMMON, mage.cards.r.Reprieve.class)); cards.add(new SetCardInfo("Reprieve", 26, Rarity.UNCOMMON, mage.cards.r.Reprieve.class));
cards.add(new SetCardInfo("Samwise the Stouthearted", 28, Rarity.UNCOMMON, mage.cards.s.SamwiseTheStouthearted.class)); cards.add(new SetCardInfo("Samwise the Stouthearted", 28, Rarity.UNCOMMON, mage.cards.s.SamwiseTheStouthearted.class));

View file

@ -16,14 +16,6 @@ public class Constructed extends DeckValidator {
private static final Logger logger = Logger.getLogger(Constructed.class); private static final Logger logger = Logger.getLogger(Constructed.class);
private static final List<String> anyNumberCardsAllowed = new ArrayList<>(Arrays.asList(
"Relentless Rats", "Shadowborn Apostle", "Rat Colony",
"Persistent Petitioners", "Seven Dwarves", "Dragon's Approach"
));
protected static final List<String> basicLandNames = new ArrayList<>(Arrays.asList(
"Forest", "Island", "Mountain", "Swamp", "Plains", "Wastes", "Snow-Covered Forest",
"Snow-Covered Island", "Snow-Covered Mountain", "Snow-Covered Swamp", "Snow-Covered Plains"
));
protected List<String> banned = new ArrayList<>(); protected List<String> banned = new ArrayList<>();
protected List<String> restricted = new ArrayList<>(); protected List<String> restricted = new ArrayList<>();
protected List<String> setCodes = new ArrayList<>(); protected List<String> setCodes = new ArrayList<>();
@ -351,13 +343,7 @@ public class Constructed extends DeckValidator {
protected boolean checkCounts(int maxCopies, Map<String, Integer> counts) { protected boolean checkCounts(int maxCopies, Map<String, Integer> counts) {
boolean valid = true; boolean valid = true;
for (Entry<String, Integer> entry : counts.entrySet()) { for (Entry<String, Integer> entry : counts.entrySet()) {
if (entry.getValue() > maxCopies if (entry.getValue() > getMaxCopies(entry.getKey(), maxCopies)) {
&& !basicLandNames.contains(entry.getKey())
&& !anyNumberCardsAllowed.contains(entry.getKey())) {
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
valid = false;
}
if (entry.getValue() > 7 && entry.getKey().equals("Seven Dwarves")) {
addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true); addError(DeckValidatorErrorType.OTHER, entry.getKey(), "Too many: " + entry.getValue(), true);
valid = false; valid = false;
} }

View file

@ -11,6 +11,32 @@ import java.util.stream.Collectors;
*/ */
public abstract class DeckValidator implements Serializable { public abstract class DeckValidator implements Serializable {
protected static final List<String> basicLandNames = Arrays.asList(
"Plains",
"Island",
"Swamp",
"Mountain",
"Forest",
"Wastes",
"Snow-Covered Plains",
"Snow-Covered Island",
"Snow-Covered Swamp",
"Snow-Covered Mountain",
"Snow-Covered Forest"
);
protected static final Map<String, Integer> maxCopiesMap = new HashMap<>();
static {
basicLandNames.stream().forEach(s -> maxCopiesMap.put(s, Integer.MAX_VALUE));
maxCopiesMap.put("Relentless Rats", Integer.MAX_VALUE);
maxCopiesMap.put("Shadowborn Apostle", Integer.MAX_VALUE);
maxCopiesMap.put("Rat Colony", Integer.MAX_VALUE);
maxCopiesMap.put("Persistent Petitioners", Integer.MAX_VALUE);
maxCopiesMap.put("Dragon's Approach", Integer.MAX_VALUE);
maxCopiesMap.put("Seven Dwarves", 7);
maxCopiesMap.put("Nazgul", 9);
}
protected String name; protected String name;
protected String shortName; protected String shortName;
protected List<DeckValidatorError> errorsList = new ArrayList<>(); protected List<DeckValidatorError> errorsList = new ArrayList<>();
@ -141,4 +167,8 @@ public abstract class DeckValidator implements Serializable {
public abstract int getDeckMinSize(); public abstract int getDeckMinSize();
public abstract int getSideboardMinSize(); public abstract int getSideboardMinSize();
protected static final int getMaxCopies(String name, int defaultAmount) {
return maxCopiesMap.getOrDefault(name, defaultAmount);
}
} }