diff --git a/Mage.Sets/src/mage/sets/innistrad/GhostlyPossession.java b/Mage.Sets/src/mage/sets/innistrad/GhostlyPossession.java new file mode 100644 index 0000000000..f86894afc9 --- /dev/null +++ b/Mage.Sets/src/mage/sets/innistrad/GhostlyPossession.java @@ -0,0 +1,135 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.innistrad; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Rarity; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.PreventionEffectImpl; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continious.GainAbilityAttachedEffect; +import mage.abilities.keyword.EnchantAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.DamageEvent; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author BetaSteward + */ +public class GhostlyPossession extends CardImpl { + + public GhostlyPossession(UUID ownerId) { + super(ownerId, 18, "Ghostly Possession", Rarity.COMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); + this.expansionSetCode = "ISD"; + this.subtype.add("Aura"); + + this.color.setWhite(true); + + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Constants.Outcome.AddAbility)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + //Enchanted creature has flying + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FlyingAbility.getInstance(), Constants.AttachmentType.AURA))); + + //Prevent all combat damage that would be dealt to and dealt by enchanted creature + this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new GhostlyPossessionEffect())); + } + + public GhostlyPossession(final GhostlyPossession card) { + super(card); + } + + @Override + public GhostlyPossession copy() { + return new GhostlyPossession(this); + } +} + +class GhostlyPossessionEffect extends PreventionEffectImpl { + + public GhostlyPossessionEffect() { + super(Duration.WhileOnBattlefield); + staticText = "Prevent all combat damage that would be dealt to and dealt by enchanted creature"; + } + + public GhostlyPossessionEffect(final GhostlyPossessionEffect effect) { + super(effect); + } + + @Override + public GhostlyPossessionEffect copy() { + return new GhostlyPossessionEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), event.getAmount(), false); + if (!game.replaceEvent(preventEvent)) { + int damage = event.getAmount(); + event.setAmount(0); + game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getFirstTarget(), source.getId(), source.getControllerId(), damage)); + } + return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (super.applies(event, source, game) && event instanceof DamageEvent) { + DamageEvent damageEvent = (DamageEvent) event; + if (damageEvent.isCombatDamage()) { + Permanent aura = game.getPermanent(source.getSourceId()); + if (aura != null && aura.getAttachedTo() != null) { + if (event.getSourceId().equals(aura.getAttachedTo()) || event.getTargetId().equals(aura.getAttachedTo())) { + return true; + } + } + } + } + return false; + } + +} diff --git a/Mage.Sets/src/mage/sets/innistrad/MentorOfTheMeek.java b/Mage.Sets/src/mage/sets/innistrad/MentorOfTheMeek.java new file mode 100644 index 0000000000..d2a8816a43 --- /dev/null +++ b/Mage.Sets/src/mage/sets/innistrad/MentorOfTheMeek.java @@ -0,0 +1,111 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ + +package mage.sets.innistrad; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.common.DoIfCostPaid; +import mage.abilities.effects.common.DrawCardControllerEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.game.permanent.Permanent; + +/** + * @author Loki + */ +public class MentorOfTheMeek extends CardImpl { + + public MentorOfTheMeek(UUID ownerId) { + super(ownerId, 21, "Mentor of the Meek", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{W}"); + this.expansionSetCode = "ISD"; + this.subtype.add("Human"); + this.subtype.add("Soldier"); + this.color.setWhite(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + //Whenever another creature with power 2 or less enters the battlefield under your control, you may pay 1. If you do, draw a card. + this.addAbility(new MentorOfTheMeekAbility()); + + } + + public MentorOfTheMeek(final MentorOfTheMeek card) { + super(card); + } + + @Override + public MentorOfTheMeek copy() { + return new MentorOfTheMeek(this); + } + +} + +class MentorOfTheMeekAbility extends TriggeredAbilityImpl { + + public MentorOfTheMeekAbility() { + super(Constants.Zone.BATTLEFIELD, new DoIfCostPaid(new DrawCardControllerEffect(1), new ManaCostsImpl("{1}")), true); + } + + public MentorOfTheMeekAbility(final MentorOfTheMeekAbility ability) { + super(ability); + } + + @Override + public MentorOfTheMeekAbility copy() { + return new MentorOfTheMeekAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ZONE_CHANGE && !event.getTargetId().equals(this.getSourceId())) { + ZoneChangeEvent zEvent = (ZoneChangeEvent)event; + if (zEvent.getToZone() == Constants.Zone.BATTLEFIELD) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && permanent.getCardType().contains(CardType.CREATURE) && permanent.getControllerId().equals(this.getControllerId()) && permanent.getPower().getValue() <= 2) { + return true; + } + } + } + return false; + } + + @Override + public String getRule() { + return "Whenever another creature with power 2 or less enters the battlefield under your control, you may pay {1}. If you do, draw a card."; + } + +} diff --git a/Mage.Sets/src/mage/sets/innistrad/Nevermore.java b/Mage.Sets/src/mage/sets/innistrad/Nevermore.java new file mode 100644 index 0000000000..e10f20f221 --- /dev/null +++ b/Mage.Sets/src/mage/sets/innistrad/Nevermore.java @@ -0,0 +1,149 @@ +/* + * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.sets.innistrad; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.ReplacementEffectImpl; +import mage.cards.CardImpl; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; +import mage.players.Player; +import mage.sets.Sets; + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class Nevermore extends CardImpl { + + public Nevermore(UUID ownerId) { + super(ownerId, 25, "Nevermore", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{W}"); + this.expansionSetCode = "ISD"; + this.color.setWhite(true); + + //As Nevermore enters the battlefield, name a nonland card. + this.addAbility(new EntersBattlefieldTriggeredAbility(new NevermoreEffect1())); + + //The named card can't be cast. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NevermoreEffect2())); + + } + + public Nevermore(final Nevermore card) { + super(card); + } + + @Override + public Nevermore copy() { + return new Nevermore(this); + } + +} +class NevermoreEffect1 extends OneShotEffect { + + public NevermoreEffect1() { + super(Outcome.Detriment); + staticText = "name a nonland card"; + } + + public NevermoreEffect1(final NevermoreEffect1 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Choice cardChoice = new ChoiceImpl(); + cardChoice.setChoices(Sets.getNonLandCardNames()); + cardChoice.clearChoice(); + controller.choose(Outcome.Detriment, cardChoice, game); + String cardName = cardChoice.getChoice(); + game.getState().setValue(source.getSourceId().toString(), cardName); + } + return false; + } + + @Override + public NevermoreEffect1 copy() { + return new NevermoreEffect1(this); + } + +} + +class NevermoreEffect2 extends ReplacementEffectImpl { + + public NevermoreEffect2() { + super(Duration.WhileOnBattlefield, Outcome.Detriment); + staticText = "The named card can't be cast"; + } + + public NevermoreEffect2(final NevermoreEffect2 effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public NevermoreEffect2 copy() { + return new NevermoreEffect2(this); + } + + @Override + public boolean replaceEvent(GameEvent event, Ability source, Game game) { + return true; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (event.getType() == EventType.CAST_SPELL) { + MageObject object = game.getObject(event.getSourceId()); + if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { + return true; + } + } + return false; + } + +} diff --git a/Mage/src/mage/abilities/effects/common/PreventAllCombatDamageEffect.java b/Mage/src/mage/abilities/effects/common/PreventAllCombatDamageEffect.java index 4dabf4b96e..f39d220a42 100644 --- a/Mage/src/mage/abilities/effects/common/PreventAllCombatDamageEffect.java +++ b/Mage/src/mage/abilities/effects/common/PreventAllCombatDamageEffect.java @@ -33,6 +33,7 @@ import mage.Constants.PhaseStep; import mage.abilities.Ability; import mage.abilities.effects.PreventionEffectImpl; import mage.game.Game; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; /** @@ -74,8 +75,10 @@ public class PreventAllCombatDamageEffect extends PreventionEffectImpl