From c41c9c1f94373a7b663f3e7535ae2b792dfa9d7b Mon Sep 17 00:00:00 2001 From: jeffwadsworth <jeffwadsworth@magefree> Date: Thu, 19 Apr 2012 16:12:19 -0500 Subject: [PATCH] - Added Guard Gomazoa. <ROE> --- .../sets/riseoftheeldrazi/GuardGomazoa.java | 72 +++++++++++++++ .../PreventCombatDamageSourceEffect.java | 87 +++++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/riseoftheeldrazi/GuardGomazoa.java create mode 100644 Mage/src/mage/abilities/effects/common/PreventCombatDamageSourceEffect.java diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/GuardGomazoa.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/GuardGomazoa.java new file mode 100644 index 0000000000..56b056f5b1 --- /dev/null +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/GuardGomazoa.java @@ -0,0 +1,72 @@ +/* + * 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.riseoftheeldrazi; + +import java.util.UUID; +import mage.Constants; +import mage.Constants.CardType; +import mage.Constants.Rarity; +import mage.MageInt; +import mage.abilities.effects.common.PreventCombatDamageSourceEffect; +import mage.abilities.keyword.DefenderAbility; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.abilities.common.SimpleStaticAbility; +import mage.Constants.Zone; + +/** + * + * @author jeffwadsworth + */ +public class GuardGomazoa extends CardImpl<GuardGomazoa> { + + public GuardGomazoa(UUID ownerId) { + super(ownerId, 70, "Guard Gomazoa", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{2}{U}"); + this.expansionSetCode = "ROE"; + this.subtype.add("Jellyfish"); + + this.color.setBlue(true); + this.power = new MageInt(1); + this.toughness = new MageInt(3); + + this.addAbility(DefenderAbility.getInstance()); + this.addAbility(FlyingAbility.getInstance()); + + // Prevent all combat damage that would be dealt to Guard Gomazoa. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventCombatDamageSourceEffect(Constants.Duration.WhileOnBattlefield))); + } + + public GuardGomazoa(final GuardGomazoa card) { + super(card); + } + + @Override + public GuardGomazoa copy() { + return new GuardGomazoa(this); + } +} diff --git a/Mage/src/mage/abilities/effects/common/PreventCombatDamageSourceEffect.java b/Mage/src/mage/abilities/effects/common/PreventCombatDamageSourceEffect.java new file mode 100644 index 0000000000..f1e07aab5b --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/PreventCombatDamageSourceEffect.java @@ -0,0 +1,87 @@ +/* + * 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.effects.common; + +import mage.Constants.Duration; +import mage.abilities.Ability; +import mage.abilities.effects.PreventionEffectImpl; +import mage.game.Game; +import mage.game.events.DamageEvent; +import mage.game.events.GameEvent; + +/** + * + * @author jeffwadsworth + */ +public class PreventCombatDamageSourceEffect extends PreventionEffectImpl<PreventCombatDamageSourceEffect> { + + public PreventCombatDamageSourceEffect(Duration duration) { + super(duration); + staticText = "Prevent all damage that would be dealt to {this} " + duration.toString(); + } + + public PreventCombatDamageSourceEffect(final PreventCombatDamageSourceEffect effect) { + super(effect); + } + + @Override + public PreventCombatDamageSourceEffect copy() { + return new PreventCombatDamageSourceEffect(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 true; + } + return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (super.applies(event, source, game)) { + DamageEvent damageEvent = (DamageEvent) event; + if (event.getTargetId().equals(source.getSourceId()) && damageEvent.isCombatDamage()) { + return true; + } + } + return false; + } + +} +