diff --git a/Mage.Sets/src/mage/cards/g/GuardianGladewalker.java b/Mage.Sets/src/mage/cards/g/GuardianGladewalker.java index 5a31053888f..19ab91720aa 100644 --- a/Mage.Sets/src/mage/cards/g/GuardianGladewalker.java +++ b/Mage.Sets/src/mage/cards/g/GuardianGladewalker.java @@ -27,7 +27,7 @@ public final class GuardianGladewalker extends CardImpl { this.toughness = new MageInt(1); // Changeling - this.isAllCreatureTypes(); + this.setIsAllCreatureTypes(true); this.addAbility(ChangelingAbility.getInstance()); // When Guardian Gladewalker enters the battlefield, put a +1/+1 counter on target creature. diff --git a/Mage.Sets/src/mage/cards/w/Withercrown.java b/Mage.Sets/src/mage/cards/w/Withercrown.java index 60cc2098d06..6bddb9302ab 100644 --- a/Mage.Sets/src/mage/cards/w/Withercrown.java +++ b/Mage.Sets/src/mage/cards/w/Withercrown.java @@ -1,72 +1,72 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package mage.cards.w; - -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.costs.common.SacrificeSourceCost; -import mage.abilities.effects.Effect; -import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.DoUnlessControllerPaysEffect; -import mage.abilities.effects.common.LoseLifeSourceControllerEffect; -import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; -import mage.abilities.effects.common.continuous.SetPowerEnchantedEffect; -import mage.abilities.keyword.EnchantAbility; -import mage.cards.CardImpl; -import mage.cards.CardSetInfo; -import mage.constants.AttachmentType; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.SubType; -import mage.constants.TargetController; -import mage.constants.Zone; -import mage.target.TargetPermanent; -import mage.target.common.TargetCreaturePermanent; - -/** - * - * @author jeffwadsworth - */ -public final class Withercrown extends CardImpl { - - public Withercrown(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}"); - - this.subtype.add(SubType.AURA); - - final String rule = "Do you want to sacrifice the enchanted creature? If not, you lose 1 life."; - - // Enchant creature - TargetPermanent auraTarget = new TargetCreaturePermanent(); - this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); - Ability ability = new EnchantAbility(auraTarget.getTargetName()); - this.addAbility(ability); - - // Enchanted creature has base power 0 and has “At the beginning of your upkeep, you lose 1 life unless you sacrifice this creature." - Ability abilityTest = new SimpleStaticAbility(new SetPowerEnchantedEffect(0)); - Effect effect2 = new DoUnlessControllerPaysEffect(new LoseLifeSourceControllerEffect(1), - new SacrificeSourceCost(), rule); - effect2.setText("you lose 1 life unless you sacrifice this creature."); - Effect effect3 = new GainAbilityAttachedEffect(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, - effect2, TargetController.YOU, false, false, null), AttachmentType.AURA); - effect3.setText("and has “At the beginning of your upkeep, you lose 1 life unless you sacrifice this creature."); - abilityTest.addEffect(effect3); - this.addAbility(abilityTest); - - } - - private Withercrown(final Withercrown card) { - super(card); - } - - @Override - public Withercrown copy() { - return new Withercrown(this); - } -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.cards.w; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.common.SacrificeSourceCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DoUnlessControllerPaysEffect; +import mage.abilities.effects.common.LoseLifeSourceControllerEffect; +import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; +import mage.abilities.effects.common.continuous.SetPowerEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author jeffwadsworth + */ +public final class Withercrown extends CardImpl { + + public Withercrown(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}"); + + this.subtype.add(SubType.AURA); + + final String rule = "Do you want to sacrifice the enchanted creature? If not, you lose 1 life."; + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Enchanted creature has base power 0 and has “At the beginning of your upkeep, you lose 1 life unless you sacrifice this creature." + Ability abilityTest = new SimpleStaticAbility(new SetPowerEnchantedEffect(0)); + Effect effect2 = new DoUnlessControllerPaysEffect(new LoseLifeSourceControllerEffect(1), + new SacrificeSourceCost(), rule); + effect2.setText("you lose 1 life unless you sacrifice this creature."); + Effect effect3 = new GainAbilityAttachedEffect(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, + effect2, TargetController.YOU, false, false, null), AttachmentType.AURA); + effect3.setText("and has “At the beginning of your upkeep, you lose 1 life unless you sacrifice this creature."); + abilityTest.addEffect(effect3); + this.addAbility(abilityTest); + + } + + private Withercrown(final Withercrown card) { + super(card); + } + + @Override + public Withercrown copy() { + return new Withercrown(this); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAttachedControllerPaysEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAttachedControllerPaysEffect.java index 0ba9b4f2730..1104846c589 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAttachedControllerPaysEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DoUnlessAttachedControllerPaysEffect.java @@ -1,112 +1,112 @@ -package mage.abilities.effects.common; - -import mage.abilities.Ability; -import mage.abilities.Mode; -import mage.abilities.costs.Cost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; -import mage.abilities.effects.Effects; -import mage.abilities.effects.OneShotEffect; -import mage.constants.Outcome; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; -import mage.util.CardUtil; - -/** - * - * @author jeffwadsworth - */ -public class DoUnlessAttachedControllerPaysEffect extends OneShotEffect { - - protected Effects executingEffects = new Effects(); - private final Cost cost; - private String chooseUseText; - - public DoUnlessAttachedControllerPaysEffect(Effect effect, Cost cost) { - this(effect, cost, null); - } - - public DoUnlessAttachedControllerPaysEffect(Effect effect, Cost cost, String chooseUseText) { - super(Outcome.Neutral); - this.executingEffects.add(effect); - this.cost = cost; - this.chooseUseText = chooseUseText; - } - - public DoUnlessAttachedControllerPaysEffect(final DoUnlessAttachedControllerPaysEffect effect) { - super(effect); - this.executingEffects = effect.executingEffects.copy(); - this.cost = effect.cost.copy(); - this.chooseUseText = effect.chooseUseText; - } - - public void addEffect(Effect effect) { - executingEffects.add(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId()); - if (aura == null) { - return false; - } - Permanent attachedTo = game.getPermanentOrLKIBattlefield(aura.getAttachedTo()); - if (attachedTo == null) { - return false; - } - Player controllerOfAttachedTo = game.getPlayer(attachedTo.getControllerId()); - if (controllerOfAttachedTo != null) { - String message; - if (chooseUseText == null) { - String effectText = executingEffects.getText(source.getModes().getMode()); - message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?"; - } else { - message = chooseUseText; - } - message = CardUtil.replaceSourceName(message, aura.getName()); - boolean result = true; - boolean doEffect = true; - - // check if controller is willing to pay - if (cost.canPay(source, source, controllerOfAttachedTo.getId(), game) - && controllerOfAttachedTo.chooseUse(Outcome.Neutral, message, source, game)) { - cost.clearPaid(); - if (cost.pay(source, game, source, controllerOfAttachedTo.getId(), false, null)) { - if (!game.isSimulation()) { - game.informPlayers(controllerOfAttachedTo.getLogName() + " pays the cost to prevent the effect"); - } - doEffect = false; - } - } - - // do the effects if not paid - if (doEffect) { - for (Effect effect : executingEffects) { - effect.setTargetPointer(this.targetPointer); - if (effect instanceof OneShotEffect) { - result &= effect.apply(game, source); - } else { - game.addEffect((ContinuousEffect) effect, source); - } - } - } - return result; - } - return false; - } - - @Override - public String getText(Mode mode) { - if (!staticText.isEmpty()) { - return staticText; - } - String effectsText = executingEffects.getText(mode); - return effectsText.substring(0, effectsText.length() - 1) + " unless controller pays " + cost.getText(); - } - - @Override - public DoUnlessAttachedControllerPaysEffect copy() { - return new DoUnlessAttachedControllerPaysEffect(this); - } -} +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.costs.Cost; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.Effect; +import mage.abilities.effects.Effects; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.util.CardUtil; + +/** + * + * @author jeffwadsworth + */ +public class DoUnlessAttachedControllerPaysEffect extends OneShotEffect { + + protected Effects executingEffects = new Effects(); + private final Cost cost; + private String chooseUseText; + + public DoUnlessAttachedControllerPaysEffect(Effect effect, Cost cost) { + this(effect, cost, null); + } + + public DoUnlessAttachedControllerPaysEffect(Effect effect, Cost cost, String chooseUseText) { + super(Outcome.Neutral); + this.executingEffects.add(effect); + this.cost = cost; + this.chooseUseText = chooseUseText; + } + + public DoUnlessAttachedControllerPaysEffect(final DoUnlessAttachedControllerPaysEffect effect) { + super(effect); + this.executingEffects = effect.executingEffects.copy(); + this.cost = effect.cost.copy(); + this.chooseUseText = effect.chooseUseText; + } + + public void addEffect(Effect effect) { + executingEffects.add(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent aura = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if (aura == null) { + return false; + } + Permanent attachedTo = game.getPermanentOrLKIBattlefield(aura.getAttachedTo()); + if (attachedTo == null) { + return false; + } + Player controllerOfAttachedTo = game.getPlayer(attachedTo.getControllerId()); + if (controllerOfAttachedTo != null) { + String message; + if (chooseUseText == null) { + String effectText = executingEffects.getText(source.getModes().getMode()); + message = "Pay " + cost.getText() + " to prevent (" + effectText.substring(0, effectText.length() - 1) + ")?"; + } else { + message = chooseUseText; + } + message = CardUtil.replaceSourceName(message, aura.getName()); + boolean result = true; + boolean doEffect = true; + + // check if controller is willing to pay + if (cost.canPay(source, source, controllerOfAttachedTo.getId(), game) + && controllerOfAttachedTo.chooseUse(Outcome.Neutral, message, source, game)) { + cost.clearPaid(); + if (cost.pay(source, game, source, controllerOfAttachedTo.getId(), false, null)) { + if (!game.isSimulation()) { + game.informPlayers(controllerOfAttachedTo.getLogName() + " pays the cost to prevent the effect"); + } + doEffect = false; + } + } + + // do the effects if not paid + if (doEffect) { + for (Effect effect : executingEffects) { + effect.setTargetPointer(this.targetPointer); + if (effect instanceof OneShotEffect) { + result &= effect.apply(game, source); + } else { + game.addEffect((ContinuousEffect) effect, source); + } + } + } + return result; + } + return false; + } + + @Override + public String getText(Mode mode) { + if (!staticText.isEmpty()) { + return staticText; + } + String effectsText = executingEffects.getText(mode); + return effectsText.substring(0, effectsText.length() - 1) + " unless controller pays " + cost.getText(); + } + + @Override + public DoUnlessAttachedControllerPaysEffect copy() { + return new DoUnlessAttachedControllerPaysEffect(this); + } +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerEnchantedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerEnchantedEffect.java index d1534d51882..3f74d4cf841 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerEnchantedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/SetPowerEnchantedEffect.java @@ -1,50 +1,50 @@ -package mage.abilities.effects.common.continuous; - -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffectImpl; -import mage.constants.Duration; -import mage.constants.Layer; -import mage.constants.Outcome; -import mage.constants.SubLayer; -import mage.game.Game; -import mage.game.permanent.Permanent; - -/** - * - * @author jeffwadsworth - */ -public class SetPowerEnchantedEffect extends ContinuousEffectImpl { - - private final int power; - - public SetPowerEnchantedEffect(int power) { - super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.Neutral); - staticText = "Enchanted creature has base power " + power; - this.power = power; - } - - public SetPowerEnchantedEffect(final SetPowerEnchantedEffect effect) { - super(effect); - this.power = effect.power; - } - - @Override - public SetPowerEnchantedEffect copy() { - return new SetPowerEnchantedEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment != null - && enchantment.getAttachedTo() != null) { - Permanent enchanted = game.getPermanent(enchantment.getAttachedTo()); - if (enchanted != null) { - enchanted.getPower().setValue(power); - } - return true; - } - return false; - } - -} +package mage.abilities.effects.common.continuous; + +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author jeffwadsworth + */ +public class SetPowerEnchantedEffect extends ContinuousEffectImpl { + + private final int power; + + public SetPowerEnchantedEffect(int power) { + super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.Neutral); + staticText = "Enchanted creature has base power " + power; + this.power = power; + } + + public SetPowerEnchantedEffect(final SetPowerEnchantedEffect effect) { + super(effect); + this.power = effect.power; + } + + @Override + public SetPowerEnchantedEffect copy() { + return new SetPowerEnchantedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent enchantment = game.getPermanent(source.getSourceId()); + if (enchantment != null + && enchantment.getAttachedTo() != null) { + Permanent enchanted = game.getPermanent(enchantment.getAttachedTo()); + if (enchanted != null) { + enchanted.getPower().setValue(power); + } + return true; + } + return false; + } + +}