[STX] fixed Journey to the Oracle not returning to hand (fixes #7827)

This commit is contained in:
Evan Kranzler 2021-05-18 18:42:18 -04:00
parent e9189f1d9d
commit a85bf3af79

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.common; package mage.abilities.effects.common;
import mage.MageObject; import mage.MageObject;
@ -9,6 +8,7 @@ import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
/** /**
@ -56,7 +56,9 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if (controller != null) { if (controller == null) {
return false;
}
MageObject mageObject; MageObject mageObject;
if (returnFromNextZone if (returnFromNextZone
&& game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) { && game.getState().getZoneChangeCounter(source.getSourceId()) == source.getSourceObjectZoneChangeCounter() + 1) {
@ -64,7 +66,9 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
} else { } else {
mageObject = source.getSourceObjectIfItStillExists(game); mageObject = source.getSourceObjectIfItStillExists(game);
} }
if (mageObject != null) { if (mageObject == null) {
return true;
}
switch (game.getState().getZone(mageObject.getId())) { switch (game.getState().getZone(mageObject.getId())) {
case BATTLEFIELD: case BATTLEFIELD:
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
@ -74,13 +78,13 @@ public class ReturnToHandSourceEffect extends OneShotEffect {
break; break;
case GRAVEYARD: case GRAVEYARD:
Card card = (Card) mageObject; Card card = (Card) mageObject;
if (!fromBattlefieldOnly) { return !fromBattlefieldOnly && controller.moveCards(card, Zone.HAND, source, game);
return 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 true;
} }
return false;
}
} }