From a9a8fef8690bb12702cb3cd1a59cae825cfe6578 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sat, 5 Oct 2013 19:13:00 +0200 Subject: [PATCH] * Obzedat, Ghost Council - Fixed a bug that Obzedat came alo back to battlefield if it was exiled by another effect responding to his own exile effect. --- .../sets/gatecrash/ObzedatGhostCouncil.java | 72 +++++++++++++++++-- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java b/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java index bee6b16ff1b..38339301579 100644 --- a/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java +++ b/Mage.Sets/src/mage/sets/gatecrash/ObzedatGhostCouncil.java @@ -38,18 +38,22 @@ import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; -import mage.abilities.effects.common.ExileSourceEffect; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.LoseLifeTargetEffect; -import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlSourceEffect; import mage.abilities.effects.common.continious.GainAbilitySourceEffect; import mage.abilities.keyword.HasteAbility; +import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.TargetController; +import mage.constants.Zone; +import mage.game.ExileZone; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.target.common.TargetOpponent; /** @@ -77,7 +81,7 @@ public class ObzedatGhostCouncil extends CardImpl { ability.addTarget(new TargetOpponent(true)); this.addAbility(ability); //At the beginning of your end step you may exile Obzedat. If you do, return it to the battlefield under it's owner's control at the beginning of your next upkeep. It gains haste. - Ability ability2 = new BeginningOfYourEndStepTriggeredAbility(new ExileSourceEffect(), true); + Ability ability2 = new BeginningOfYourEndStepTriggeredAbility(new ObzedatGhostCouncilExileSourceEffect(), true); ability2.addEffect(new CreateDelayedTriggeredAbilityEffect(new BeginningOfYourUpkeepdelayTriggeredAbility())); this.addAbility(ability2); } @@ -92,10 +96,38 @@ public class ObzedatGhostCouncil extends CardImpl { } } + +class ObzedatGhostCouncilExileSourceEffect extends OneShotEffect { + + public ObzedatGhostCouncilExileSourceEffect() { + super(Outcome.Exile); + staticText = "Exile {this}"; + } + + public ObzedatGhostCouncilExileSourceEffect(final ObzedatGhostCouncilExileSourceEffect effect) { + super(effect); + } + + @Override + public ObzedatGhostCouncilExileSourceEffect copy() { + return new ObzedatGhostCouncilExileSourceEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + return permanent.moveToExile(source.getSourceId(),permanent.getName(), source.getId(), game); + } + return false; + } + +} + class BeginningOfYourUpkeepdelayTriggeredAbility extends DelayedTriggeredAbility { public BeginningOfYourUpkeepdelayTriggeredAbility() { - this(new ReturnToBattlefieldUnderOwnerControlSourceEffect(), TargetController.YOU); + this(new ObzedatGhostCouncilReturnEffect(), TargetController.YOU); this.addEffect(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.EndOfTurn)); } @@ -125,3 +157,35 @@ class BeginningOfYourUpkeepdelayTriggeredAbility extends DelayedTriggeredAbility return "If you do, return it to the battlefield under it's owner's control at the beginning of your next upkeep. It gains haste"; } } + +class ObzedatGhostCouncilReturnEffect extends OneShotEffect { + + public ObzedatGhostCouncilReturnEffect() { + super(Outcome.Benefit); + } + + public ObzedatGhostCouncilReturnEffect(final ObzedatGhostCouncilReturnEffect effect) { + super(effect); + } + + @Override + public ObzedatGhostCouncilReturnEffect copy() { + return new ObzedatGhostCouncilReturnEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Card card = game.getCard(source.getSourceId()); + if (card != null) { + ExileZone currentZone = game.getState().getExile().getExileZone(source.getSourceId()); + // return it only from the own exile zone + if (currentZone.size() > 0) { + if (card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId(), false)) { + return true; + } + } + } + return false; + } + +}