[SNC] Implemented Ledger Shredder

This commit is contained in:
Evan Kranzler 2022-04-07 19:58:37 -04:00
parent 495a0ab776
commit 75bd6cf906
6 changed files with 142 additions and 25 deletions

View file

@ -56,7 +56,7 @@ public final class HowlingMoon extends CardImpl {
}
class HowlingMoonTriggeredAbility extends TriggeredAbilityImpl {
// TODO: replace this and others like it with CastSecondSpellTriggeredAbility
public HowlingMoonTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenEffect(new WolfToken()));
}

View file

@ -0,0 +1,43 @@
package mage.cards.l;
import mage.MageInt;
import mage.abilities.common.CastSecondSpellTriggeredAbility;
import mage.abilities.effects.keyword.ConniveSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.TargetController;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class LedgerShredder extends CardImpl {
public LedgerShredder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.subtype.add(SubType.BIRD);
this.subtype.add(SubType.ADVISOR);
this.power = new MageInt(1);
this.toughness = new MageInt(3);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever a player casts their second spell each turn, Ledger Shredder connives.
this.addAbility(new CastSecondSpellTriggeredAbility(new ConniveSourceEffect(), TargetController.ANY));
}
private LedgerShredder(final LedgerShredder card) {
super(card);
}
@Override
public LedgerShredder copy() {
return new LedgerShredder(this);
}
}

View file

@ -31,6 +31,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet {
cards.add(new SetCardInfo("Island", 264, Rarity.LAND, mage.cards.basiclands.Island.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Jetmir's Garden", 250, Rarity.RARE, mage.cards.j.JetmirsGarden.class));
cards.add(new SetCardInfo("Jetmir, Nexus of Revels", 193, Rarity.MYTHIC, mage.cards.j.JetmirNexusOfRevels.class));
cards.add(new SetCardInfo("Ledger Shredder", 46, Rarity.RARE, mage.cards.l.LedgerShredder.class));
cards.add(new SetCardInfo("Lord Xander, the Collector", 197, Rarity.MYTHIC, mage.cards.l.LordXanderTheCollector.class));
cards.add(new SetCardInfo("Maestros Charm", 199, Rarity.UNCOMMON, mage.cards.m.MaestrosCharm.class));
cards.add(new SetCardInfo("Mountain", 268, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));

View file

@ -6,6 +6,7 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -17,19 +18,28 @@ import mage.watchers.common.CastSpellLastTurnWatcher;
public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
private static final Hint hint = new ValueHint("Spells you cast this turn", SpellCastValue.instance);
private final TargetController targetController;
public CastSecondSpellTriggeredAbility(Effect effect) {
this(Zone.BATTLEFIELD, effect, false);
this(effect, TargetController.YOU);
}
public CastSecondSpellTriggeredAbility(Zone zone, Effect effect, boolean optional) {
public CastSecondSpellTriggeredAbility(Effect effect, TargetController targetController) {
this(Zone.BATTLEFIELD, effect, targetController, false);
}
public CastSecondSpellTriggeredAbility(Zone zone, Effect effect, TargetController targetController, boolean optional) {
super(zone, effect, optional);
this.addWatcher(new CastSpellLastTurnWatcher());
this.addHint(hint);
if (targetController == TargetController.YOU) {
this.addHint(hint);
}
this.targetController = targetController;
}
private CastSecondSpellTriggeredAbility(final CastSecondSpellTriggeredAbility ability) {
super(ability);
this.targetController = ability.targetController;
}
@Override
@ -39,8 +49,21 @@ public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(event.getPlayerId())) {
return false;
switch (targetController) {
case YOU:
if (!isControlledBy(event.getPlayerId())) {
return false;
}
break;
case OPPONENT:
if (!game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
return false;
}
break;
case ANY:
break;
default:
throw new IllegalArgumentException("TargetController " + targetController + " not supported");
}
CastSpellLastTurnWatcher watcher = game.getState().getWatcher(CastSpellLastTurnWatcher.class);
return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) == 2;
@ -48,7 +71,16 @@ public class CastSecondSpellTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getTriggerPhrase() {
return "Whenever you cast your second spell each turn, " ;
switch (targetController) {
case YOU:
return "Whenever you cast your second spell each turn, ";
case OPPONENT:
return "Whenever an opponent casts their second spell each turn, ";
case ANY:
return "Whenever a player casts their second spell each turn, ";
default:
throw new IllegalArgumentException("TargetController " + targetController + " not supported");
}
}
@Override

View file

@ -0,0 +1,58 @@
package mage.abilities.effects.keyword;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* @author TheElk801
*/
public class ConniveSourceEffect extends OneShotEffect {
public ConniveSourceEffect() {
super(Outcome.Benefit);
staticText = "{this} connives. <i>(Draw a card, then discard a card. " +
"If you discarded a nonland card, put a +1/+1 counter on this creature.)</i>";
}
private ConniveSourceEffect(final ConniveSourceEffect effect) {
super(effect);
}
@Override
public ConniveSourceEffect copy() {
return new ConniveSourceEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null) {
return false;
}
return permanent != null && connive(permanent, 1, source, game);
}
public static boolean connive(Permanent permanent, int amount, Ability source, Game game) {
if (amount < 1) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
if (player == null) {
return false;
}
player.drawCards(amount, source, game);
int counters = player
.discard(amount, false, false, source, game)
.count(StaticFilters.FILTER_CARDS_NON_LAND, game);
if (counters > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(counters), source, game);
}
return true;
}
}

View file

@ -6,11 +6,8 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* @author TheElk801
@ -44,22 +41,8 @@ public class ConniveTargetEffect extends OneShotEffect {
if (permanent == null) {
return false;
}
Player player = game.getPlayer(permanent.getControllerId());
if (player == null) {
return false;
}
int amount = xValue.calculate(game, source, this);
if (amount < 1) {
return false;
}
player.drawCards(amount, source, game);
int counters = player.discard(
amount, false, false, source, game
).count(StaticFilters.FILTER_CARDS_NON_LAND, game);
if (counters > 0) {
permanent.addCounters(CounterType.P1P1.createInstance(counters), source, game);
}
return true;
return amount > 0 && ConniveSourceEffect.connive(permanent, amount, source, game);
}
@Override