From 5d71be877dc963f6a92c2ee48a8415b0af2359c8 Mon Sep 17 00:00:00 2001 From: Loki Date: Thu, 14 Apr 2011 17:18:17 +0300 Subject: [PATCH] some cards and Fear mechanic --- .../sets/magic2010/LightningElemental.java | 58 ++++++++++ Mage.Sets/src/mage/sets/magic2010/Megrim.java | 57 ++++++++++ .../src/mage/sets/tenth/EarthElemental.java | 61 +++++++++++ .../mage/sets/tenth/LightningElemental.java | 63 +++++++++++ Mage.Sets/src/mage/sets/tenth/Megrim.java | 95 ++++++++++++++++ .../src/mage/sets/tenth/RavenousRats.java | 70 ++++++++++++ .../src/mage/sets/tenth/SeveredLegion.java | 63 +++++++++++ .../mage/abilities/keyword/FearAbility.java | 102 ++++++++++++++++++ 8 files changed, 569 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/magic2010/LightningElemental.java create mode 100644 Mage.Sets/src/mage/sets/magic2010/Megrim.java create mode 100644 Mage.Sets/src/mage/sets/tenth/EarthElemental.java create mode 100644 Mage.Sets/src/mage/sets/tenth/LightningElemental.java create mode 100644 Mage.Sets/src/mage/sets/tenth/Megrim.java create mode 100644 Mage.Sets/src/mage/sets/tenth/RavenousRats.java create mode 100644 Mage.Sets/src/mage/sets/tenth/SeveredLegion.java create mode 100644 Mage/src/mage/abilities/keyword/FearAbility.java diff --git a/Mage.Sets/src/mage/sets/magic2010/LightningElemental.java b/Mage.Sets/src/mage/sets/magic2010/LightningElemental.java new file mode 100644 index 0000000000..69a788c825 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2010/LightningElemental.java @@ -0,0 +1,58 @@ +/* + * 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.magic2010; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.cards.CardImpl; + +/** + * + * @author Loki + */ +public class LightningElemental extends mage.sets.tenth.LightningElemental { + + public LightningElemental (UUID ownerId) { + super(ownerId); + this.cardNumber = 147; + this.expansionSetCode = "M10"; + } + + public LightningElemental (final LightningElemental card) { + super(card); + } + + @Override + public LightningElemental copy() { + return new LightningElemental(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/magic2010/Megrim.java b/Mage.Sets/src/mage/sets/magic2010/Megrim.java new file mode 100644 index 0000000000..5082584701 --- /dev/null +++ b/Mage.Sets/src/mage/sets/magic2010/Megrim.java @@ -0,0 +1,57 @@ +/* + * 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.magic2010; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.cards.CardImpl; + +/** + * + * @author Loki + */ +public class Megrim extends mage.sets.tenth.Megrim { + + public Megrim (UUID ownerId) { + super(ownerId); + this.cardNumber = 104; + this.expansionSetCode = "M10"; + } + + public Megrim (final Megrim card) { + super(card); + } + + @Override + public Megrim copy() { + return new Megrim(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/tenth/EarthElemental.java b/Mage.Sets/src/mage/sets/tenth/EarthElemental.java new file mode 100644 index 0000000000..ceaad318c8 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/EarthElemental.java @@ -0,0 +1,61 @@ +/* + * 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.tenth; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.cards.CardImpl; + +/** + * + * @author Loki + */ +public class EarthElemental extends CardImpl { + + public EarthElemental (UUID ownerId) { + super(ownerId, 199, "Earth Elemental", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{R}{R}"); + this.expansionSetCode = "10E"; + this.subtype.add("Elemental"); + this.color.setRed(true); + this.power = new MageInt(4); + this.toughness = new MageInt(5); + } + + public EarthElemental (final EarthElemental card) { + super(card); + } + + @Override + public EarthElemental copy() { + return new EarthElemental(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/tenth/LightningElemental.java b/Mage.Sets/src/mage/sets/tenth/LightningElemental.java new file mode 100644 index 0000000000..df5b3e11cf --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/LightningElemental.java @@ -0,0 +1,63 @@ +/* + * 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.tenth; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.keyword.HasteAbility; +import mage.cards.CardImpl; + +/** + * + * @author Loki + */ +public class LightningElemental extends CardImpl { + + public LightningElemental (UUID ownerId) { + super(ownerId, 217, "Lightning Elemental", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{R}"); + this.expansionSetCode = "10E"; + this.subtype.add("Elemental"); + this.color.setRed(true); + this.power = new MageInt(4); + this.toughness = new MageInt(1); + this.addAbility(HasteAbility.getInstance()); + } + + public LightningElemental (final LightningElemental card) { + super(card); + } + + @Override + public LightningElemental copy() { + return new LightningElemental(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/tenth/Megrim.java b/Mage.Sets/src/mage/sets/tenth/Megrim.java new file mode 100644 index 0000000000..49a785bb5b --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/Megrim.java @@ -0,0 +1,95 @@ +/* + * 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.tenth; + +import java.util.UUID; + +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.common.TargetOpponent; + +/** + * + * @author Loki + */ +public class Megrim extends CardImpl { + + public Megrim (UUID ownerId) { + super(ownerId, 157, "Megrim", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}"); + this.expansionSetCode = "10E"; + this.color.setBlack(true); + this.addAbility(new MergimTriggeredAbility()); + } + + public Megrim (final Megrim card) { + super(card); + } + + @Override + public Megrim copy() { + return new Megrim(this); + } + +} + +class MergimTriggeredAbility extends TriggeredAbilityImpl { + MergimTriggeredAbility() { + super(Constants.Zone.BATTLEFIELD, new DamageTargetEffect(2)); + this.addTarget(new TargetOpponent()); + } + + MergimTriggeredAbility(final MergimTriggeredAbility ability) { + super(ability); + } + + @Override + public MergimTriggeredAbility copy() { + return new MergimTriggeredAbility(this); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DISCARDED_CARD && game.getOpponents(this.getControllerId()).contains(event.getPlayerId())) { + this.getTargets().get(0).add(event.getPlayerId(), game); + return true; + } + return false; + } + + @Override + public String getRule() { + return "Whenever an opponent discards a card, Megrim deals 2 damage to that player."; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/tenth/RavenousRats.java b/Mage.Sets/src/mage/sets/tenth/RavenousRats.java new file mode 100644 index 0000000000..2f03596e6c --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/RavenousRats.java @@ -0,0 +1,70 @@ +/* + * 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.tenth; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.Abilities; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.costs.common.DiscardTargetCost; +import mage.abilities.effects.common.DiscardTargetEffect; +import mage.cards.CardImpl; +import mage.target.common.TargetOpponent; + +/** + * + * @author Loki + */ +public class RavenousRats extends CardImpl { + + public RavenousRats (UUID ownerId) { + super(ownerId, 171, "Ravenous Rats", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}"); + this.expansionSetCode = "10E"; + this.subtype.add("Rat"); + this.color.setBlack(true); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + Ability ability = new EntersBattlefieldTriggeredAbility(new DiscardTargetEffect(1)); + ability.addTarget(new TargetOpponent()); + this.addAbility(ability); + } + + public RavenousRats (final RavenousRats card) { + super(card); + } + + @Override + public RavenousRats copy() { + return new RavenousRats(this); + } + +} diff --git a/Mage.Sets/src/mage/sets/tenth/SeveredLegion.java b/Mage.Sets/src/mage/sets/tenth/SeveredLegion.java new file mode 100644 index 0000000000..d3b961e742 --- /dev/null +++ b/Mage.Sets/src/mage/sets/tenth/SeveredLegion.java @@ -0,0 +1,63 @@ +/* + * 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.tenth; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.keyword.FearAbility; +import mage.cards.CardImpl; + +/** + * + * @author Loki + */ +public class SeveredLegion extends CardImpl { + + public SeveredLegion (UUID ownerId) { + super(ownerId, 177, "Severed Legion", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{B}{B}"); + this.expansionSetCode = "10E"; + this.subtype.add("Zombie"); + this.color.setBlack(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + this.addAbility(FearAbility.getInstance()); + } + + public SeveredLegion (final SeveredLegion card) { + super(card); + } + + @Override + public SeveredLegion copy() { + return new SeveredLegion(this); + } + +} diff --git a/Mage/src/mage/abilities/keyword/FearAbility.java b/Mage/src/mage/abilities/keyword/FearAbility.java new file mode 100644 index 0000000000..fce57cbacb --- /dev/null +++ b/Mage/src/mage/abilities/keyword/FearAbility.java @@ -0,0 +1,102 @@ +/* +* 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.abilities.keyword; + +import java.io.ObjectStreamException; +import mage.Constants.Duration; +import mage.abilities.Ability; +import mage.abilities.EvasionAbility; +import mage.abilities.effects.RestrictionEffect; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author Loki + */ +public class FearAbility extends EvasionAbility { + + private static final FearAbility fINSTANCE = new FearAbility(); + + private Object readResolve() throws ObjectStreamException { + return fINSTANCE; + } + + public static FearAbility getInstance() { + return fINSTANCE; + } + + private FearAbility() { + this.addEffect(new FearEffect()); + } + + @Override + public String getRule() { + return "Fear"; + } + + @Override + public FearAbility copy() { + return fINSTANCE; + } + +} + +class FearEffect extends RestrictionEffect { + + public FearEffect() { + super(Duration.WhileOnBattlefield); + } + + public FearEffect(final FearEffect effect) { + super(effect); + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + if (permanent.getAbilities().containsKey(FearAbility.getInstance().getId())) { + return true; + } + return false; + } + + @Override + public boolean canBlock(Permanent attacker, Permanent blocker, Game game) { + if (blocker.getAbilities().containsKey(FearAbility.getInstance().getId()) || blocker.getColor().isBlack()) { + return true; + } + return false; + } + + @Override + public FearEffect copy() { + return new FearEffect(this); + } + +} \ No newline at end of file