mirror of
https://github.com/correl/mage.git
synced 2025-03-25 21:05:04 -09:00
[USG] rework Veiled Sentry
This commit is contained in:
parent
8c1eaed974
commit
77382152e7
1 changed files with 28 additions and 23 deletions
|
@ -1,15 +1,14 @@
|
|||
package mage.cards.v;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbility;
|
||||
import mage.abilities.common.SpellCastOpponentTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.SourceMatchesFilterCondition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.FilterSpell;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -22,14 +21,17 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class VeiledSentry extends CardImpl {
|
||||
|
||||
private static final Condition condition = new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT);
|
||||
|
||||
public VeiledSentry(UUID ownerId, CardSetInfo setInfo) {
|
||||
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.
|
||||
TriggeredAbility ability = new SpellCastOpponentTriggeredAbility(Zone.BATTLEFIELD, new VeiledSentryEffect(), new FilterSpell(), false, SetTargetPointer.SPELL);
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(ability, new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_ENCHANTMENT),
|
||||
"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."));
|
||||
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
|
||||
new SpellCastOpponentTriggeredAbility(new VeiledSentryEffect(), false),
|
||||
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) {
|
||||
|
@ -44,6 +46,8 @@ public final class VeiledSentry extends CardImpl {
|
|||
|
||||
class VeiledSentryEffect extends ContinuousEffectImpl {
|
||||
|
||||
private int spellMV = 0;
|
||||
|
||||
public VeiledSentryEffect() {
|
||||
super(Duration.Custom, Outcome.BecomeCreature);
|
||||
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
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent veiledSentry = game.getPermanent(source.getSourceId());
|
||||
Spell spellCast = game.getSpell(targetPointer.getFirst(game, source));
|
||||
if (spellCast != null) {
|
||||
game.getState().setValue(source + "cmcSpell", spellCast.getManaValue());
|
||||
public void init(Ability source, Game game) {
|
||||
Spell spell = (Spell) getValue("spellCast");
|
||||
if (spell != null) {
|
||||
spellMV = spell.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;
|
||||
}
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
veiledSentry.removeAllCardTypes(game);
|
||||
veiledSentry.removeAllSubTypes(game);
|
||||
veiledSentry.addCardType(game, CardType.CREATURE);
|
||||
veiledSentry.addSubType(game, SubType.ILLUSION);
|
||||
permanent.removeAllCardTypes(game);
|
||||
permanent.removeAllSubTypes(game);
|
||||
permanent.addCardType(game, CardType.CREATURE);
|
||||
permanent.addSubType(game, SubType.ILLUSION);
|
||||
break;
|
||||
|
||||
case PTChangingEffects_7:
|
||||
if (game.getState().getValue(source + "cmcSpell") != null) {
|
||||
int cmc = (int) game.getState().getValue(source + "cmcSpell");
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
veiledSentry.addPower(cmc);
|
||||
veiledSentry.addToughness(cmc);
|
||||
}
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setModifiedBaseValue(spellMV);
|
||||
permanent.getToughness().setModifiedBaseValue(spellMV);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue