fix casting from opponent's graveyard

This commit is contained in:
xenohedron 2024-05-27 17:23:24 -04:00
parent 437f2ba231
commit 69e9f3de8a
2 changed files with 7 additions and 1 deletions

View file

@ -1,6 +1,7 @@
package mage.abilities.common;
import mage.MageIdentifier;
import mage.MageObject;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
@ -79,12 +80,14 @@ class CastFromGraveyardOnceEffect extends AsThoughEffectImpl {
Player controller = game.getPlayer(source.getControllerId());
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
CastFromGraveyardOnceWatcher watcher = game.getState().getWatcher(CastFromGraveyardOnceWatcher.class);
if (controller == null || sourcePermanent == null || watcher == null) {
Card cardToCast = game.getCard(objectId);
if (controller == null || sourcePermanent == null || watcher == null || cardToCast == null) {
return false;
}
if (game.isActivePlayer(playerId) // only during your turn
&& source.isControlledBy(playerId) // only you may cast
&& Zone.GRAVEYARD.equals(game.getState().getZone(objectId)) // from graveyard
&& cardToCast.getOwnerId().equals(playerId) // only your graveyard
&& affectedAbility instanceof SpellAbility // characteristics to check
&& watcher.abilityNotUsed(new MageObjectReference(sourcePermanent, game)) // once per turn
) {