From e393ac420195218dfb0928ebef9a7b377d7e5936 Mon Sep 17 00:00:00 2001 From: "maurer.it" Date: Wed, 12 Jan 2011 19:30:03 -0500 Subject: [PATCH 1/3] Razor Hippogriff --- .../sets/scarsofmirrodin/RazorHippogriff.java | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 Mage.Sets/src/mage/sets/scarsofmirrodin/RazorHippogriff.java diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/RazorHippogriff.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/RazorHippogriff.java new file mode 100644 index 00000000000..222710d90d6 --- /dev/null +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/RazorHippogriff.java @@ -0,0 +1,117 @@ +/* + * 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.scarsofmirrodin; + +import java.util.UUID; +import mage.Constants.CardType; +import mage.Constants.Outcome; +import mage.Constants.Rarity; +import mage.Constants.Zone; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.filter.FilterCard; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetCardInYourGraveyard; + +/** + * TODO: Javadoc me + * + * @author maurer.it_at_gmail.com + */ +public class RazorHippogriff extends CardImpl { + + private static final FilterCard filter; + + static { + filter = new FilterCard(); + filter.getCardType().add(CardType.ARTIFACT); + } + + public RazorHippogriff(UUID ownerId) { + super(ownerId, 17, "Razor Hippogriff", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); + this.expansionSetCode = "SOM"; + this.subtype.add("Hippogriff"); + this.color.setWhite(true); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + this.addAbility(FlyingAbility.getInstance()); + Ability etbAbility = new EntersBattlefieldTriggeredAbility(new RazorHippogriffEffect()); + etbAbility.addTarget(new TargetCardInYourGraveyard(filter)); + this.addAbility(etbAbility); + } + + public RazorHippogriff(final RazorHippogriff card) { + super(card); + } + + @Override + public RazorHippogriff copy() { + return new RazorHippogriff(this); + } +} + +class RazorHippogriffEffect extends OneShotEffect { + + private static final String effectText = "return target artifact card from your graveyard to your hand. You gain life equal to that card's converted mana cost"; + + RazorHippogriffEffect ( ) { + super(Outcome.ReturnToHand); + } + + RazorHippogriffEffect ( final RazorHippogriffEffect effect ) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Card card = game.getCard(source.getFirstTarget()); + Player player = game.getPlayer(source.getControllerId()); + if (card != null) { + player.gainLife(card.getManaCost().convertedManaCost(), game); + return card.moveToZone(Zone.HAND, source.getId(), game, true); + } + return false; + } + + @Override + public RazorHippogriffEffect copy() { + return new RazorHippogriffEffect(this); + } + + @Override + public String getText(Ability source) { + return effectText; + } +} From fa76561b8600f246983142eba831c0b0fb0c29ab Mon Sep 17 00:00:00 2001 From: "maurer.it" Date: Fri, 14 Jan 2011 10:12:31 -0500 Subject: [PATCH 2/3] Possible modifications for Issue 26/601.2e --- Mage/src/mage/game/GameState.java | 1 + Mage/src/mage/game/stack/Spell.java | 26 +++++++++++++++++++++++ Mage/src/mage/game/stack/SpellStack.java | 6 ++++++ Mage/src/mage/game/stack/StackObject.java | 1 + 4 files changed, 34 insertions(+) diff --git a/Mage/src/mage/game/GameState.java b/Mage/src/mage/game/GameState.java index 16531d4f4cb..ddc1bb051ad 100644 --- a/Mage/src/mage/game/GameState.java +++ b/Mage/src/mage/game/GameState.java @@ -240,6 +240,7 @@ public class GameState implements Serializable, Copyable { for (Player player: players.values()) { player.reset(); } + stack.reset(game); battlefield.reset(game); effects.apply(game); } diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index a5ec7178f39..6d0443e0c62 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -41,12 +41,16 @@ import mage.MageObject; import mage.ObjectColor; import mage.abilities.Abilities; import mage.abilities.Ability; +import mage.abilities.costs.AlternativeCost; +import mage.abilities.costs.Cost; +import mage.abilities.costs.Costs; import mage.abilities.costs.mana.ManaCost; import mage.abilities.costs.mana.ManaCosts; import mage.abilities.effects.common.ExileSpellEffect; import mage.abilities.keyword.KickerAbility; import mage.cards.Card; import mage.game.events.GameEvent; +import mage.players.ManaPool; import mage.players.Player; import mage.target.Target; import mage.watchers.Watchers; @@ -153,6 +157,28 @@ public class Spell> implements StackObject, Card { card.moveToZone(Zone.GRAVEYARD, sourceId, game, false); } + @Override + public void reset ( Game game ) { + Mana oldPayment = ability.getManaCosts().getPayment(); + ManaPool tmpPool = new ManaPool(); + tmpPool.changeMana(oldPayment); + List oldAltCosts = ability.getAlternativeCosts(); + Costs oldOptionalCosts = ability.getOptionalCosts(); + Costs oldCosts = ability.getCosts(); + + //Get a fresh copy of the spell ability. + ability = card.getSpellAbility().copy(); + + //Reload all the payments for all costs. + ability.getManaCosts().assignPayment(tmpPool); + ability.getAlternativeCosts().clear(); + ability.getAlternativeCosts().addAll(oldAltCosts); + ability.getOptionalCosts().clear(); + ability.getOptionalCosts().addAll(oldOptionalCosts); + ability.getCosts().clear(); + ability.getCosts().addAll(oldCosts); + } + @Override public UUID getSourceId() { return card.getId(); diff --git a/Mage/src/mage/game/stack/SpellStack.java b/Mage/src/mage/game/stack/SpellStack.java index 6e23e68798f..e1a26e55d03 100644 --- a/Mage/src/mage/game/stack/SpellStack.java +++ b/Mage/src/mage/game/stack/SpellStack.java @@ -134,6 +134,12 @@ public class SpellStack extends Stack { return null; } + public void reset ( Game game ) { + for ( StackObject stackObject : this ) { + stackObject.reset(game); + } + } + public SpellStack copy() { return new SpellStack(this); } diff --git a/Mage/src/mage/game/stack/StackObject.java b/Mage/src/mage/game/stack/StackObject.java index b81d86a7b49..041f3355210 100644 --- a/Mage/src/mage/game/stack/StackObject.java +++ b/Mage/src/mage/game/stack/StackObject.java @@ -41,6 +41,7 @@ public interface StackObject extends MageObject { public UUID getControllerId(); public void checkTriggers(GameEvent event, Game game); public void counter(UUID sourceId, Game game); + public void reset ( Game game ); @Override public StackObject copy(); } From 608ecac08bd39c1b4b2700ef0345936a6c28a56b Mon Sep 17 00:00:00 2001 From: "maurer.it" Date: Fri, 14 Jan 2011 10:13:40 -0500 Subject: [PATCH 3/3] Requires previous commit to work properly. If that commit is deemed to be not the greatest implementation this implementation may need modified. --- .../src/mage/sets/worldwake/EyeofUgin.java | 137 +++++------------- 1 file changed, 39 insertions(+), 98 deletions(-) diff --git a/Mage.Sets/src/mage/sets/worldwake/EyeofUgin.java b/Mage.Sets/src/mage/sets/worldwake/EyeofUgin.java index 36cbf6b408a..cc1fa8512d3 100644 --- a/Mage.Sets/src/mage/sets/worldwake/EyeofUgin.java +++ b/Mage.Sets/src/mage/sets/worldwake/EyeofUgin.java @@ -30,23 +30,26 @@ package mage.sets.worldwake; import java.util.UUID; import mage.Constants.CardType; +import mage.Constants.Duration; +import mage.Constants.Layer; +import mage.Constants.Outcome; import mage.Constants.Rarity; +import mage.Constants.SubLayer; import mage.Constants.Zone; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.SpellAbility; import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.SearchLibraryRevealPutInHandEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.filter.common.FilterCreatureCard; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.events.ZoneChangeEvent; import mage.game.stack.Spell; +import mage.game.stack.SpellStack; +import mage.game.stack.StackObject; import mage.target.common.TargetCardInLibrary; /** @@ -70,7 +73,7 @@ public class EyeofUgin extends CardImpl { this.supertype.add("Legendary"); this.subtype.add("Land"); - this.addAbility(new EyeofUginCostReductionAbility()); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EyeofUginCostReductionEffect())); Ability searchAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(filter)), new TapSourceCost()); searchAbility.addCost(new ManaCostsImpl("{7}")); this.addAbility(searchAbility); @@ -86,112 +89,50 @@ public class EyeofUgin extends CardImpl { } } -/** - * Implemented as a {@link TriggeredAbilityImpl} for now as there currently is - * no other way of interacting with a cards casting cost from an external object. - * This ability has no effect as of right now until a better way of implementing - * this form of object interaction is designed and implemented. - * - * @author maurer.it_at_gmail.com - */ -class EyeofUginCostReductionAbility extends TriggeredAbilityImpl { +class EyeofUginCostReductionEffect extends ContinuousEffectImpl { - private static final String abilityText = "Colorless Eldrazi spells you cast cost {2} less to cast."; + private static final String effectText = "Colorless Eldrazi spells you cast cost {2} less to cast"; - EyeofUginCostReductionAbility() { - super(Zone.BATTLEFIELD, null); + EyeofUginCostReductionEffect ( ) { + super(Duration.WhileOnBattlefield, Layer.TextChangingEffects_3, SubLayer.NA, Outcome.Benefit); } - EyeofUginCostReductionAbility ( EyeofUginCostReductionAbility effect ) { + EyeofUginCostReductionEffect(EyeofUginCostReductionEffect effect) { super(effect); } @Override - public boolean checkTrigger(GameEvent event, Game game) { - if ( event.getType() == EventType.ZONE_CHANGE && - event.getPlayerId().equals(this.getControllerId()) && - ((ZoneChangeEvent)event).getToZone() == Zone.STACK ) - { - Card card = (Card)game.getObject(event.getTargetId()); - Spell spell = (Spell)game.getObject(event.getSourceId()); - if ( card.getSubtype().contains("Eldrazi") ) { - ManaCosts costs = spell.getSpellAbility().getManaCosts(); - costs.load("{" + (card.getManaCost().convertedManaCost() - 2) + "}"); + public boolean apply(Game game, Ability source) { + SpellStack stack = game.getStack(); + boolean applied = false; + + for ( int idx = 0; idx < stack.size(); idx++ ) { + StackObject stackObject = stack.get(idx); + + if ( stackObject instanceof Spell && + ((Spell)stackObject).getSubtype().contains("Eldrazi")) + { + SpellAbility spell = ((Spell)stackObject).getSpellAbility(); + int previousCost = spell.getManaCosts().convertedManaCost(); + int adjustedCost = 0; + if ( (previousCost - 2) > 0 ) { + adjustedCost = previousCost - 2; + } + spell.getManaCosts().load("{" + adjustedCost + "}"); + applied = true; } } - return false; + + return applied; } @Override - public EyeofUginCostReductionAbility copy() { - return new EyeofUginCostReductionAbility(this); + public EyeofUginCostReductionEffect copy() { + return new EyeofUginCostReductionEffect(this); } @Override - public String getRule() { - return abilityText; + public String getText(Ability source) { + return effectText; } } - -//class EyeofUginCostReductionEffect extends ContinuousEffectImpl { -// -// private static final String effectText = "Colorless Eldrazi spells you cast cost {2} less to cast"; -// -// EyeofUginCostReductionEffect ( ) { -// super(Duration.WhileOnBattlefield, Layer.TextChangingEffects_3, SubLayer.NA, Outcome.Benefit); -// } -// -// EyeofUginCostReductionEffect(EyeofUginCostReductionEffect effect) { -// super(effect); -// } -// -// @Override -// public void init(Ability source, Game game) { -// super.init(source, game); -// if (this.affectedObjectsSet) { -// SpellStack stack = game.getStack(); -// for ( int idx = 0; idx < stack.size(); idx++ ) { -// StackObject stackObject = stack.get(idx); -// -// if ( stackObject instanceof Spell && -// !objects.contains(stackObject.getId()) && -// ((Spell)stackObject).getSubtype().contains("Eldrazi")) -// { -// objects.add(stackObject.getId()); -// } -// } -// } -// } -// -// @Override -// public boolean apply(Game game, Ability source) { -// SpellStack stack = game.getStack(); -// boolean applied = false; -// -// for ( int idx = 0; idx < stack.size(); idx++ ) { -// StackObject stackObject = stack.get(idx); -// -// if ( stackObject instanceof Spell && -// !objects.contains(stackObject.getId()) && -// ((Spell)stackObject).getSubtype().contains("Eldrazi")) -// { -// SpellAbility spell = ((Spell)stackObject).getSpellAbility(); -// int previousCost = spell.getManaCosts().convertedManaCost(); -// spell.getManaCosts().load("{" + (previousCost - 2) + "}"); -// applied |= objects.add(stackObject.getId()); -// } -// } -// -// return applied; -// } -// -// @Override -// public EyeofUginCostReductionEffect copy() { -// return new EyeofUginCostReductionEffect(this); -// } -// -// @Override -// public String getText(Ability source) { -// return effectText; -// } -//}