From 17bcd6ffb5c44f326db52c4ae7cc7ecbf6eaa45b Mon Sep 17 00:00:00 2001 From: shieldal Date: Sat, 16 Aug 2014 18:10:17 -0700 Subject: [PATCH 1/3] Add Angus Mackenzie --- .../src/mage/sets/legends/AngusMackenzie.java | 212 ++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/legends/AngusMackenzie.java diff --git a/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java b/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java new file mode 100644 index 0000000000..bb514d1a01 --- /dev/null +++ b/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java @@ -0,0 +1,212 @@ +/* + * 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.legends; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.ActivatedAbilityImpl; +import mage.abilities.condition.Condition; +import mage.abilities.costs.Cost; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.Effect; +import mage.abilities.effects.PreventionEffectImpl; +import mage.cards.CardImpl; +import mage.abilities.Mode; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.PhaseStep; +import mage.constants.Rarity; +import mage.constants.Zone; +import mage.filter.FilterPermanent; +import mage.game.events.DamageEvent; +import mage.game.events.GameEvent; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author shieldal + */ +public class AngusMackenzie extends CardImpl { + + public AngusMackenzie(UUID ownerId) { + super(ownerId, 257, "Angus Mackenzie", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{G}{W}{U}"); + this.expansionSetCode = "LEG"; + this.supertype.add("Legendary"); + this.subtype.add("Human"); + this.subtype.add("Cleric"); + + this.color.setWhite(true); + this.color.setBlue(true); + this.color.setGreen(true); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // {G}{W}{U}, {tap}: Prevent all combat damage that would be dealt this turn. Activate this ability only before the combat damage step. + Ability ability = new AngusMackenzieActivateIfConditionActivatedAbility( + Zone.BATTLEFIELD, + new AngusMackenziePreventAllCombatDamage(Duration.EndOfTurn), + new ManaCostsImpl("{G}{W}{U}"), + BeforeCombatDamageCondition.getInstance() + ); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } + + public AngusMackenzie(final AngusMackenzie card) { + super(card); + } + + @Override + public AngusMackenzie copy() { + return new AngusMackenzie(this); + } +} + +class AngusMackenzieActivateIfConditionActivatedAbility extends ActivatedAbilityImpl { + + private final Condition condition; + + public AngusMackenzieActivateIfConditionActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition) { + super(zone, effect, cost); + this.condition = condition; + } + + public AngusMackenzieActivateIfConditionActivatedAbility(AngusMackenzieActivateIfConditionActivatedAbility ability) { + super(ability); + this.condition = ability.condition; + } + + @Override + public boolean canActivate(UUID playerId, Game game) { + if (condition.apply(game, this)) { + return super.canActivate(playerId, game); + } + return false; + } + + @Override + public boolean activate(Game game, boolean noMana) { + if (canActivate(this.controllerId, game)) { + return super.activate(game, noMana); + } + return false; + } + + @Override + public boolean resolve(Game game) { + if (super.resolve(game)) { + return true; + } + return false; + } + + @Override + public String getRule() { + StringBuilder sb = new StringBuilder(super.getRule()); + sb.append(" Activate this ability only "); + if (condition.toString() != null) { + sb.append(condition.toString()).append("."); + } else { + sb.append(" [Condition toSting() == null] "); + } + return sb.toString(); + } + + @Override + public AngusMackenzieActivateIfConditionActivatedAbility copy() { + return new AngusMackenzieActivateIfConditionActivatedAbility(this); + } + +} + +class BeforeCombatDamageCondition implements Condition { + private static final BeforeCombatDamageCondition fInstance = new BeforeCombatDamageCondition(); + + public static Condition getInstance() { + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + PhaseStep phaseStep = game.getStep().getType(); + if(phaseStep.getIndex() < PhaseStep.FIRST_COMBAT_DAMAGE.getIndex()) { + return true; + } + return false; + } + + @Override + public String toString() { + return "before the combat damage step"; + } +} +class AngusMackenziePreventAllCombatDamage extends PreventionEffectImpl { + + private FilterPermanent filter; + + public AngusMackenziePreventAllCombatDamage(Duration duration) { + super(duration); + } + + public AngusMackenziePreventAllCombatDamage(final AngusMackenziePreventAllCombatDamage effect) { + super(effect); + if (effect.filter != null) { + this.filter = effect.filter.copy(); + } + } + + @Override + public AngusMackenziePreventAllCombatDamage copy() { + return new AngusMackenziePreventAllCombatDamage(this); + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) { + DamageEvent damageEvent = (DamageEvent) event; + if (damageEvent.isCombatDamage()) { + if (filter == null) { + return true; + } + Permanent permanent = game.getPermanent(damageEvent.getSourceId()); + if (permanent != null && filter.match(permanent, game)) { + return true; + } + } + } + return false; + } + + @Override + public String getText(Mode mode) { + return "Prevent all combat damage that would be dealt this turn"; + } +} \ No newline at end of file From 5f76cf7716aea959ae72462e63f40eb2e3805cd4 Mon Sep 17 00:00:00 2001 From: shieldal Date: Sun, 17 Aug 2014 01:37:47 -0700 Subject: [PATCH 2/3] Change Angus Mackenzie to use existing classes --- .../src/mage/sets/legends/AngusMackenzie.java | 105 +----------------- 1 file changed, 4 insertions(+), 101 deletions(-) diff --git a/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java b/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java index bb514d1a01..9889a4ce71 100644 --- a/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java +++ b/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java @@ -31,11 +31,13 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.ActivatedAbilityImpl; +import mage.abilities.common.ActivateIfConditionActivatedAbility; import mage.abilities.condition.Condition; import mage.abilities.costs.Cost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; +import mage.abilities.effects.common.PreventAllDamageByAllEffect; import mage.abilities.effects.PreventionEffectImpl; import mage.cards.CardImpl; import mage.abilities.Mode; @@ -70,9 +72,9 @@ public class AngusMackenzie extends CardImpl { this.toughness = new MageInt(2); // {G}{W}{U}, {tap}: Prevent all combat damage that would be dealt this turn. Activate this ability only before the combat damage step. - Ability ability = new AngusMackenzieActivateIfConditionActivatedAbility( + Ability ability = new ActivateIfConditionActivatedAbility( Zone.BATTLEFIELD, - new AngusMackenziePreventAllCombatDamage(Duration.EndOfTurn), + new PreventAllDamageByAllEffect(Duration.EndOfTurn, true), new ManaCostsImpl("{G}{W}{U}"), BeforeCombatDamageCondition.getInstance() ); @@ -90,63 +92,6 @@ public class AngusMackenzie extends CardImpl { } } -class AngusMackenzieActivateIfConditionActivatedAbility extends ActivatedAbilityImpl { - - private final Condition condition; - - public AngusMackenzieActivateIfConditionActivatedAbility(Zone zone, Effect effect, Cost cost, Condition condition) { - super(zone, effect, cost); - this.condition = condition; - } - - public AngusMackenzieActivateIfConditionActivatedAbility(AngusMackenzieActivateIfConditionActivatedAbility ability) { - super(ability); - this.condition = ability.condition; - } - - @Override - public boolean canActivate(UUID playerId, Game game) { - if (condition.apply(game, this)) { - return super.canActivate(playerId, game); - } - return false; - } - - @Override - public boolean activate(Game game, boolean noMana) { - if (canActivate(this.controllerId, game)) { - return super.activate(game, noMana); - } - return false; - } - - @Override - public boolean resolve(Game game) { - if (super.resolve(game)) { - return true; - } - return false; - } - - @Override - public String getRule() { - StringBuilder sb = new StringBuilder(super.getRule()); - sb.append(" Activate this ability only "); - if (condition.toString() != null) { - sb.append(condition.toString()).append("."); - } else { - sb.append(" [Condition toSting() == null] "); - } - return sb.toString(); - } - - @Override - public AngusMackenzieActivateIfConditionActivatedAbility copy() { - return new AngusMackenzieActivateIfConditionActivatedAbility(this); - } - -} - class BeforeCombatDamageCondition implements Condition { private static final BeforeCombatDamageCondition fInstance = new BeforeCombatDamageCondition(); @@ -167,46 +112,4 @@ class BeforeCombatDamageCondition implements Condition { public String toString() { return "before the combat damage step"; } -} -class AngusMackenziePreventAllCombatDamage extends PreventionEffectImpl { - - private FilterPermanent filter; - - public AngusMackenziePreventAllCombatDamage(Duration duration) { - super(duration); - } - - public AngusMackenziePreventAllCombatDamage(final AngusMackenziePreventAllCombatDamage effect) { - super(effect); - if (effect.filter != null) { - this.filter = effect.filter.copy(); - } - } - - @Override - public AngusMackenziePreventAllCombatDamage copy() { - return new AngusMackenziePreventAllCombatDamage(this); - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) { - DamageEvent damageEvent = (DamageEvent) event; - if (damageEvent.isCombatDamage()) { - if (filter == null) { - return true; - } - Permanent permanent = game.getPermanent(damageEvent.getSourceId()); - if (permanent != null && filter.match(permanent, game)) { - return true; - } - } - } - return false; - } - - @Override - public String getText(Mode mode) { - return "Prevent all combat damage that would be dealt this turn"; - } } \ No newline at end of file From 17fdeb267aea06bcea08e7b3d9195a1c41bbbdb2 Mon Sep 17 00:00:00 2001 From: shieldal Date: Sun, 17 Aug 2014 01:40:43 -0700 Subject: [PATCH 3/3] Remove extra imports from Angus Mackenzie --- Mage.Sets/src/mage/sets/legends/AngusMackenzie.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java b/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java index 9889a4ce71..49999e43d1 100644 --- a/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java +++ b/Mage.Sets/src/mage/sets/legends/AngusMackenzie.java @@ -30,27 +30,18 @@ package mage.sets.legends; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.ActivatedAbilityImpl; import mage.abilities.common.ActivateIfConditionActivatedAbility; import mage.abilities.condition.Condition; -import mage.abilities.costs.Cost; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.PreventAllDamageByAllEffect; -import mage.abilities.effects.PreventionEffectImpl; import mage.cards.CardImpl; -import mage.abilities.Mode; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.PhaseStep; import mage.constants.Rarity; import mage.constants.Zone; -import mage.filter.FilterPermanent; -import mage.game.events.DamageEvent; -import mage.game.events.GameEvent; import mage.game.Game; -import mage.game.permanent.Permanent; /** *