[STX] Implemented Silverquill Silencer

This commit is contained in:
Evan Kranzler 2021-04-06 09:25:48 -04:00
parent b156e3b137
commit 1d4fc1369a
3 changed files with 98 additions and 22 deletions

View file

@ -0,0 +1,78 @@
package mage.cards.s;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.LoseLifeTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SetTargetPointer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterSpell;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class SilverquillSilencer extends CardImpl {
private static final FilterSpell filter = new FilterSpell("a spell with the chosen name");
static {
filter.add(SilverquillSilencerPredicate.instance);
}
public SilverquillSilencer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{B}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.CLERIC);
this.power = new MageInt(3);
this.toughness = new MageInt(2);
// As Silverquill Silencer enters the battlefield, choose a nonland card name.
this.addAbility(new AsEntersBattlefieldAbility(
new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.NON_LAND_NAME)
));
// Whenever an opponent casts a spell with the chosen name, they lose 3 life and you draw a card.
Ability ability = new SpellCastOpponentTriggeredAbility(
Zone.BATTLEFIELD, new LoseLifeTargetEffect(3).setText("they lose 3 life"),
filter, false, SetTargetPointer.PLAYER
);
ability.addEffect(new DrawCardSourceControllerEffect(1).concatBy("and you"));
this.addAbility(ability);
}
private SilverquillSilencer(final SilverquillSilencer card) {
super(card);
}
@Override
public SilverquillSilencer copy() {
return new SilverquillSilencer(this);
}
}
enum SilverquillSilencerPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<MageObject>> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<MageObject> input, Game game) {
String cardName = (String) game.getState().getValue(
input.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY
);
return CardUtil.haveSameNames(input.getObject().getName(), cardName);
}
}

View file

@ -204,6 +204,7 @@ public final class StrixhavenSchoolOfMages extends ExpansionSet {
cards.add(new SetCardInfo("Silverquill Campus", 273, Rarity.COMMON, mage.cards.s.SilverquillCampus.class)); cards.add(new SetCardInfo("Silverquill Campus", 273, Rarity.COMMON, mage.cards.s.SilverquillCampus.class));
cards.add(new SetCardInfo("Silverquill Command", 232, Rarity.RARE, mage.cards.s.SilverquillCommand.class)); cards.add(new SetCardInfo("Silverquill Command", 232, Rarity.RARE, mage.cards.s.SilverquillCommand.class));
cards.add(new SetCardInfo("Silverquill Pledgemage", 233, Rarity.COMMON, mage.cards.s.SilverquillPledgemage.class)); cards.add(new SetCardInfo("Silverquill Pledgemage", 233, Rarity.COMMON, mage.cards.s.SilverquillPledgemage.class));
cards.add(new SetCardInfo("Silverquill Silencer", 234, Rarity.RARE, mage.cards.s.SilverquillSilencer.class));
cards.add(new SetCardInfo("Snow Day", 53, Rarity.UNCOMMON, mage.cards.s.SnowDay.class)); cards.add(new SetCardInfo("Snow Day", 53, Rarity.UNCOMMON, mage.cards.s.SnowDay.class));
cards.add(new SetCardInfo("Solve the Equation", 54, Rarity.UNCOMMON, mage.cards.s.SolveTheEquation.class)); cards.add(new SetCardInfo("Solve the Equation", 54, Rarity.UNCOMMON, mage.cards.s.SolveTheEquation.class));
cards.add(new SetCardInfo("Soothsayer Adept", 55, Rarity.COMMON, mage.cards.s.SoothsayerAdept.class)); cards.add(new SetCardInfo("Soothsayer Adept", 55, Rarity.COMMON, mage.cards.s.SoothsayerAdept.class));

View file

@ -1,4 +1,3 @@
package mage.abilities.common; package mage.abilities.common;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
@ -58,28 +57,26 @@ public class SpellCastOpponentTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) { if (!game.getPlayer(this.getControllerId()).hasOpponent(event.getPlayerId(), game)) {
Spell spell = game.getStack().getSpell(event.getTargetId()); return false;
if (spell != null && filter.match(spell, game)) {
if (setTargetPointer != SetTargetPointer.NONE) {
for (Effect effect : this.getEffects()) {
switch (setTargetPointer) {
case SPELL:
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
break;
case PLAYER:
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
break;
default:
throw new UnsupportedOperationException("Value of SetTargetPointer not supported!");
}
}
}
return true;
}
} }
return false; Spell spell = game.getStack().getSpell(event.getTargetId());
if (spell == null || !filter.match(spell, getSourceId(), getControllerId(), game)) {
return false;
}
switch (setTargetPointer) {
case NONE:
break;
case SPELL:
getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
break;
case PLAYER:
getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
break;
default:
throw new UnsupportedOperationException("Value of SetTargetPointer not supported!");
}
return true;
} }
@Override @Override