[OTC] Implement Lock and Load

This commit is contained in:
Susucre 2024-04-06 15:07:07 +02:00
parent db9bf3662f
commit 788fbd26e1
2 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,77 @@
package mage.cards.l;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.IntPlusDynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.keyword.PlotAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.game.Game;
import mage.watchers.common.SpellsCastWatcher;
import java.util.Objects;
import java.util.UUID;
/**
* @author Susucr
*/
public final class LockAndLoad extends CardImpl {
private static final DynamicValue xValue = new IntPlusDynamicValue(1, LockAndLoadValue.instance);
public LockAndLoad(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}");
// Draw a card, then draw a card for each other instant and sorcery spell you've cast this turn.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(xValue)
.setText("Draw a card, then draw a card for each other instant and sorcery spell you've cast this turn"));
// Plot {3}{U}
this.addAbility(new PlotAbility("{3}{U}"));
}
private LockAndLoad(final LockAndLoad card) {
super(card);
}
@Override
public LockAndLoad copy() {
return new LockAndLoad(this);
}
}
enum LockAndLoadValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
SpellsCastWatcher watcher = game.getState().getWatcher(SpellsCastWatcher.class);
return watcher == null ? 0 :
watcher.getSpellsCastThisTurn(sourceAbility.getControllerId())
.stream()
.filter(Objects::nonNull)
.filter(s -> s.isInstantOrSorcery(game))
.filter(s -> !s.getSourceId().equals(sourceAbility.getSourceId())
|| s.getZoneChangeCounter(game) != sourceAbility.getSourceObjectZoneChangeCounter())
.mapToInt(x -> 1)
.sum();
}
@Override
public LockAndLoadValue copy() {
return this;
}
@Override
public String toString() {
return "X";
}
@Override
public String getMessage() {
return "Number of other instant and sorcery spell you've cast this turn";
}
}

View file

@ -155,6 +155,7 @@ public final class OutlawsOfThunderJunctionCommander extends ExpansionSet {
cards.add(new SetCardInfo("Life Insurance", 233, Rarity.RARE, mage.cards.l.LifeInsurance.class));
cards.add(new SetCardInfo("Lightning Greaves", 260, Rarity.UNCOMMON, mage.cards.l.LightningGreaves.class));
cards.add(new SetCardInfo("Llanowar Wastes", 305, Rarity.RARE, mage.cards.l.LlanowarWastes.class));
cards.add(new SetCardInfo("Lock and Load", 15, Rarity.RARE, mage.cards.l.LockAndLoad.class));
cards.add(new SetCardInfo("Magmatic Insight", 173, Rarity.UNCOMMON, mage.cards.m.MagmaticInsight.class));
cards.add(new SetCardInfo("Mari, the Killing Quill", 138, Rarity.RARE, mage.cards.m.MariTheKillingQuill.class));
cards.add(new SetCardInfo("Marshal's Anthem", 82, Rarity.RARE, mage.cards.m.MarshalsAnthem.class));