1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-04-09 17:00:09 -09:00

[USG] rework Veiled Sentry

This commit is contained in:
theelk801 2023-04-11 20:14:20 -04:00
parent 8c1eaed974
commit 77382152e7

View file

@ -1,15 +1,14 @@
package mage.cards.v; package mage.cards.v;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.SpellCastOpponentTriggeredAbility; import mage.abilities.common.SpellCastOpponentTriggeredAbility;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceMatchesFilterCondition; import mage.abilities.condition.common.SourceMatchesFilterCondition;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.FilterSpell;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -22,14 +21,17 @@ import java.util.UUID;
*/ */
public final class VeiledSentry extends CardImpl { public final class VeiledSentry extends CardImpl {
private static final Condition condition = new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
public VeiledSentry(UUID ownerId, CardSetInfo setInfo) { public VeiledSentry(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}");
// When an opponent casts a spell, if Veiled Sentry is an enchantment, Veiled Sentry becomes an Illusion creature with power and toughness each equal to that spell's converted mana cost. // When an opponent casts a spell, if Veiled Sentry is an enchantment, Veiled Sentry becomes an Illusion creature with power and toughness each equal to that spell's converted mana cost.
TriggeredAbility ability = new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, new VeiledSentryEffect(), new FilterSpell(), false, SetTargetPointer.SPELL); this.addAbility(new ConditionalInterveningIfTriggeredAbility(
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT), new SpellCastOpponentTriggeredAbility(new VeiledSentryEffect(), false),
"Whenever an opponent casts a spell, if Veiled Sentry is an enchantment, Veil Sentry becomes an Illusion creature with power and toughness equal to that spell's mana value.")); condition, "Whenever an opponent casts a spell, if {this} is an enchantment, " +
"{this} becomes an Illusion creature with power and toughness equal to that spell's mana value."
));
} }
private VeiledSentry(final VeiledSentry card) { private VeiledSentry(final VeiledSentry card) {
@ -44,6 +46,8 @@ public final class VeiledSentry extends CardImpl {
class VeiledSentryEffect extends ContinuousEffectImpl { class VeiledSentryEffect extends ContinuousEffectImpl {
private int spellMV = 0;
public VeiledSentryEffect() { public VeiledSentryEffect() {
super(Duration.Custom, Outcome.BecomeCreature); super(Duration.Custom, Outcome.BecomeCreature);
staticText = "{this} becomes an Illusion creature with power and toughness equal to that spell's mana value"; staticText = "{this} becomes an Illusion creature with power and toughness equal to that spell's mana value";
@ -59,30 +63,31 @@ class VeiledSentryEffect extends ContinuousEffectImpl {
} }
@Override @Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { public void init(Ability source, Game game) {
Permanent veiledSentry = game.getPermanent(source.getSourceId()); Spell spell = (Spell) getValue("spellCast");
Spell spellCast = game.getSpell(targetPointer.getFirst(game, source)); if (spell != null) {
if (spellCast != null) { spellMV = spell.getManaValue();
game.getState().setValue(source + "cmcSpell", spellCast.getManaValue());
} }
if (veiledSentry == null) { }
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent == null) {
discard();
return false; return false;
} }
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:
veiledSentry.removeAllCardTypes(game); permanent.removeAllCardTypes(game);
veiledSentry.removeAllSubTypes(game); permanent.removeAllSubTypes(game);
veiledSentry.addCardType(game, CardType.CREATURE); permanent.addCardType(game, CardType.CREATURE);
veiledSentry.addSubType(game, SubType.ILLUSION); permanent.addSubType(game, SubType.ILLUSION);
break; break;
case PTChangingEffects_7: case PTChangingEffects_7:
if (game.getState().getValue(source + "cmcSpell") != null) { if (sublayer == SubLayer.SetPT_7b) {
int cmc = (int) game.getState().getValue(source + "cmcSpell"); permanent.getPower().setModifiedBaseValue(spellMV);
if (sublayer == SubLayer.SetPT_7b) { permanent.getToughness().setModifiedBaseValue(spellMV);
veiledSentry.addPower(cmc);
veiledSentry.addToughness(cmc);
}
} }
} }
return true; return true;