// last checked card this turn is no longer exiled, so you can't cast another with this effect
// TODO: Handle if card was cast/removed from exile with effect from another card.
//       If so, this effect could prevent player from casting although they should be able to use it
@Override
    public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
        if (affectedControllerId.equals(source.getControllerId())) {
            Card card = game.getCard(objectId);
            MageObject sourceObject = source.getSourceObject(game);
            if (card != null && !card.isLand() && sourceObject != null) {
                UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
                if (exileId != null) {
                    ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
                    if (exileZone != null && exileZone.contains(objectId)) {
                        if (game.getTurnNum() == turnNumber) {
                            if (!exileZone.contains(cardId)) {
                                // last checked card this turn is no longer exiled, so you can't cast another with this effect
                                // TODO: Handle if card was cast/removed from exile with effect from another card.
                                //       If so, this effect could prevent player from casting although they should be able to use it
                                return false;
                            }
                        }
                        this.turnNumber = game.getTurnNum();
                        this.cardId = objectId;
                        return true;
                    }
                }
            }
        }
        return false;
    }
if (game.getTurnNum() == turnNumber) {
if (!exileZone.contains(cardId)) {
// last checked card this turn is no longer exiled, so you can't cast another with this effect
// TODO: Handle if card was cast/removed from exile with effect from another card.
// If so, this effect could prevent player from casting although they should be able to use it
return false;
}
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
MageObject sourceObject = source.getSourceObject(game);
if (card != null && !card.isLand() && sourceObject != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exileId != null) {
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(objectId)) {
if (game.getTurnNum() == turnNumber) {
if (!exileZone.contains(cardId)) {
// last checked card this turn is no longer exiled, so you can't cast another with this effect
// TODO: Handle if card was cast/removed from exile with effect from another card.
// If so, this effect could prevent player from casting although they should be able to use it
return false;
}
}
this.turnNumber = game.getTurnNum();
this.cardId = objectId;
return true;
}
}
}
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (affectedControllerId.equals(source.getControllerId())) {
Card card = game.getCard(objectId);
MageObject sourceObject = source.getSourceObject(game);
if (card != null && !card.isLand() && sourceObject != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exileId != null) {
ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(objectId)) {
if (game.getTurnNum() == turnNumber) {
if (!exileZone.contains(cardId)) {
// last checked card this turn is no longer exiled, so you can't cast another with this effect
// TODO: Handle if card was cast/removed from exile with effect from another card.
// If so, this effect could prevent player from casting although they should be able to use it
return false;
}
}
this.turnNumber = game.getTurnNum();
this.cardId = objectId;
return true;
}
}
}
}
return false;
}