[STX] fixed Journey to the Oracle not returning to hand (fixes
-
package mage.abilities.effects.common;
import mage.MageObject;
@@ -9,6 +8,7 @@ import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
+import mage.game.stack.Spell;
import mage.players.Player;
/**
@@ -56,7 +56,9 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
- if (controller != null) {
+ if (controller == null) {
+ return false;
+ }
MageObject mageObject;
if (returnFromNextZone
&& game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
@@ -64,7 +66,9 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
} else {
mageObject = source.getSourceObjectIfItStillExists(game);
}
- if (mageObject != null) {
+ if (mageObject == null) {
+ return true;
+ }
switch (game.getState().getZone(mageObject.getId())) {
case BATTLEFIELD:
Permanent permanent = game.getPermanent(source.getSourceId());
@@ -74,13 +78,13 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
break;
case GRAVEYARD:
Card card = (Card) mageObject;
- if (!fromBattlefieldOnly) {
- return controller.moveCards(card, Zone.HAND, source, game);
- }
- }
+ return !fromBattlefieldOnly && controller.moveCards(card, Zone.HAND, source, game);
+ case STACK:
+ Spell spell = game.getSpell(source.getSourceId());
+ return !fromBattlefieldOnly
+ && spell != null
+ && controller.moveCards(spell.getMainCard(), Zone.HAND, source, game);
}
return true;
}
- return false;
- }
}
