diff --git a/Mage.Sets/src/mage/sets/magic2015/GenesisHydra.java b/Mage.Sets/src/mage/sets/magic2015/GenesisHydra.java index cddff07a0c..9f38d6d2f9 100644 --- a/Mage.Sets/src/mage/sets/magic2015/GenesisHydra.java +++ b/Mage.Sets/src/mage/sets/magic2015/GenesisHydra.java @@ -138,11 +138,17 @@ class GenesisHydraPutOntoBattlefieldEffect extends OneShotEffect { return false; } Cards cards = new CardsImpl(); - int count = source.getManaCostsToPay().getX(); - count = Math.min(controller.getLibrary().size(), count); - for (int i = 0; i < count; i++) { - Card card = controller.getLibrary().removeFromTop(game); - cards.add(card); + + Object obj = getValue(CastSourceTriggeredAbility.SOURCE_CAST_SPELL_ABILITY); + int count = 0; + if (obj != null && obj instanceof SpellAbility) { + count = ((SpellAbility) obj).getManaCostsToPay().getX(); + // using other var because of tooltip + int size = Math.min(controller.getLibrary().size(), count); + for (int i = 0; i < size; i++) { + Card card = controller.getLibrary().removeFromTop(game); + cards.add(card); + } } if (cards.size() > 0) { diff --git a/Mage/src/mage/abilities/TriggeredAbilities.java b/Mage/src/mage/abilities/TriggeredAbilities.java index d01eff1e5f..4ae2d69551 100644 --- a/Mage/src/mage/abilities/TriggeredAbilities.java +++ b/Mage/src/mage/abilities/TriggeredAbilities.java @@ -29,12 +29,6 @@ package mage.abilities; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.UUID; import mage.MageObject; import mage.constants.Zone; import mage.game.Game; @@ -42,6 +36,8 @@ import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; +import java.util.*; + /** * @@ -78,6 +74,7 @@ public class TriggeredAbilities extends HashMap { if (object instanceof Permanent) { ability.setControllerId(((Permanent) object).getControllerId()); } + ability.setSourceObject(object); if (ability.checkTrigger(event, game)) { UUID controllerId = ability.getControllerId(); ability.trigger(game, controllerId); diff --git a/Mage/src/mage/abilities/TriggeredAbility.java b/Mage/src/mage/abilities/TriggeredAbility.java index 654d2467ff..7287003a3b 100644 --- a/Mage/src/mage/abilities/TriggeredAbility.java +++ b/Mage/src/mage/abilities/TriggeredAbility.java @@ -28,10 +28,12 @@ package mage.abilities; -import java.util.UUID; +import mage.MageObject; import mage.game.Game; import mage.game.events.GameEvent; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -41,7 +43,6 @@ public interface TriggeredAbility extends Ability { void trigger(Game game, UUID controllerId); boolean checkTrigger(GameEvent event, Game game); boolean checkInterveningIfClause(Game game); - @Override TriggeredAbility copy(); - + void setSourceObject(MageObject mageObject); } diff --git a/Mage/src/mage/abilities/TriggeredAbilityImpl.java b/Mage/src/mage/abilities/TriggeredAbilityImpl.java index ed8c6f60ea..5392ed44c6 100644 --- a/Mage/src/mage/abilities/TriggeredAbilityImpl.java +++ b/Mage/src/mage/abilities/TriggeredAbilityImpl.java @@ -28,7 +28,6 @@ package mage.abilities; -import java.util.UUID; import mage.MageObject; import mage.abilities.effects.Effect; import mage.constants.AbilityType; @@ -36,6 +35,8 @@ import mage.constants.Zone; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** * * @author BetaSteward_at_googlemail.com @@ -43,6 +44,7 @@ import mage.players.Player; public abstract class TriggeredAbilityImpl extends AbilityImpl implements TriggeredAbility { protected boolean optional; + protected MageObject sourceObject; public TriggeredAbilityImpl(Zone zone, Effect effect) { this(zone, effect, false); @@ -147,4 +149,12 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge return sb.toString(); } + + public MageObject getSourceObject() { + return sourceObject; + } + + public void setSourceObject(MageObject sourceObject) { + this.sourceObject = sourceObject; + } } diff --git a/Mage/src/mage/abilities/effects/common/CastSourceTriggeredAbility.java b/Mage/src/mage/abilities/effects/common/CastSourceTriggeredAbility.java index 78ce209450..0825e84864 100644 --- a/Mage/src/mage/abilities/effects/common/CastSourceTriggeredAbility.java +++ b/Mage/src/mage/abilities/effects/common/CastSourceTriggeredAbility.java @@ -32,6 +32,7 @@ import mage.abilities.effects.Effect; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.stack.Spell; /** * @@ -39,6 +40,8 @@ import mage.game.events.GameEvent; */ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl { + public static final String SOURCE_CAST_SPELL_ABILITY = "sourceCastSpellAbility"; + public CastSourceTriggeredAbility(Effect effect) { this(effect, false); } @@ -59,6 +62,14 @@ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getType().equals(GameEvent.EventType.SPELL_CAST) && event.getSourceId().equals(this.getSourceId())) { + if (getSourceObject() != null && getSourceObject() instanceof Spell) { + Spell spell = (Spell)getSourceObject(); + if (spell.getSpellAbility() != null) { + for (Effect effect : getEffects()) { + effect.setValue(SOURCE_CAST_SPELL_ABILITY, spell.getSpellAbility()); + } + } + } return true; } return false;