Fix issue where you could cast Adventure from exile.

This commit is contained in:
Patrick Hulin 2019-12-09 19:38:41 -05:00
parent 5af4942d15
commit a2a569195a
3 changed files with 119 additions and 12 deletions

View file

@ -5,17 +5,17 @@ import mage.abilities.MageSingleton;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.cards.AdventureCard;
import mage.cards.AdventureCardSpell;
import mage.cards.Card;
import mage.constants.AsThoughEffectType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
@ -30,6 +30,10 @@ public class ExileAdventureSpellEffect extends OneShotEffect implements MageSing
return instance;
}
public static UUID adventureExileId(UUID controllerId, Game game) {
return CardUtil.getExileZoneId(controllerId.toString() + "- On an Adventure", game);
}
private ExileAdventureSpellEffect() {
super(Outcome.Exile);
staticText = "";
@ -48,8 +52,10 @@ public class ExileAdventureSpellEffect extends OneShotEffect implements MageSing
if (spell != null && !spell.isCopy()) {
Card spellCard = spell.getCard();
if (spellCard != null && spellCard instanceof AdventureCardSpell) {
UUID exileId = adventureExileId(controller.getId(), game);
game.getExile().createZone(exileId, "On an Adventure");
AdventureCardSpell adventureSpellCard = (AdventureCardSpell) spellCard;
if (controller.moveCards(adventureSpellCard, Zone.EXILED, source, game)) {
if (controller.moveCardsToExile(adventureSpellCard, source, game, true, exileId, "On an Adventure")) {
ContinuousEffect effect = new AdventureCastFromExileEffect();
effect.setTargetPointer(new FixedTarget(adventureSpellCard.getParentCard().getId(), game));
game.addEffect(effect, source);
@ -86,10 +92,12 @@ class AdventureCastFromExileEffect extends AsThoughEffectImpl {
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
UUID targetId = getTargetPointer().getFirst(game, source);
ExileZone adventureExileZone = game.getExile().getExileZone(ExileAdventureSpellEffect.adventureExileId(affectedControllerId, game));
if (targetId == null) {
this.discard();
} else if (objectId.equals(targetId)
&& affectedControllerId.equals(source.getControllerId())) {
&& affectedControllerId.equals(source.getControllerId())
&& adventureExileZone.contains(objectId)) {
Card card = game.getCard(objectId);
return card != null;
}

View file

@ -5,10 +5,13 @@
*/
package mage.cards;
import mage.abilities.SpellAbility;
import mage.abilities.effects.common.ExileAdventureSpellEffect;
import mage.constants.CardType;
import mage.constants.SpellAbilityType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.Game;
import java.util.List;
@ -25,6 +28,7 @@ public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpe
public AdventureCardSpellImpl(UUID ownerId, CardSetInfo setInfo, CardType[] cardTypes, String costs, AdventureCard adventureCardParent) {
super(ownerId, setInfo, cardTypes, costs, SpellAbilityType.ADVENTURE_SPELL);
this.subtype.add(SubType.ADVENTURE);
this.replaceSpellAbility(new AdventureCardSpellAbility(getSpellAbility()));
this.adventureCardParent = adventureCardParent;
}
@ -89,3 +93,19 @@ public class AdventureCardSpellImpl extends CardImpl implements AdventureCardSpe
return this.adventureCardParent;
}
}
class AdventureCardSpellAbility extends SpellAbility {
public AdventureCardSpellAbility(SpellAbility ability) {
super(ability);
}
@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
ExileZone adventureExileZone = game.getExile().getExileZone(ExileAdventureSpellEffect.adventureExileId(playerId, game));
if (adventureExileZone != null && adventureExileZone.contains(this.getSourceId())) {
return ActivationStatus.getFalse();
} else {
return super.canActivate(playerId, game);
}
}
}