Search in sources :

Example 1 with ScryEffect

use of mage.abilities.effects.keyword.ScryEffect in project mage by magefree.

the class StudyHallTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!getSourceId().equals(event.getSourceId())) {
        return false;
    }
    Permanent sourcePermanent = getSourcePermanentOrLKI(game);
    if (sourcePermanent == null || sourcePermanent.getAbilities(game).stream().map(Ability::getOriginalId).map(UUID::toString).noneMatch(event.getData()::equals)) {
        return false;
    }
    Player player = game.getPlayer(getControllerId());
    Spell spell = game.getStack().getSpell(event.getTargetId());
    CommanderPlaysCountWatcher watcher = game.getState().getWatcher(CommanderPlaysCountWatcher.class);
    if (player == null || spell == null || watcher == null || !game.isCommanderObject(player, spell)) {
        return false;
    }
    getEffects().clear();
    addEffect(new ScryEffect(watcher.getPlaysCount(spell.getMainCard().getId())));
    return true;
}
Also used : Player(mage.players.Player) CommanderPlaysCountWatcher(mage.watchers.common.CommanderPlaysCountWatcher) ScryEffect(mage.abilities.effects.keyword.ScryEffect) Permanent(mage.game.permanent.Permanent) UUID(java.util.UUID) Spell(mage.game.stack.Spell)

Example 2 with ScryEffect

use of mage.abilities.effects.keyword.ScryEffect in project mage by magefree.

the class PutridCyclopEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        new ScryEffect(1).apply(game, source);
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            controller.revealCards(sourceObject.getIdName(), new CardsImpl(card), game);
            int unboost = card.getManaValue() * -1;
            ContinuousEffect effect = new BoostSourceEffect(unboost, unboost, Duration.EndOfTurn);
            game.addEffect(effect, source);
        }
        return true;
    }
    return false;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) Player(mage.players.Player) ScryEffect(mage.abilities.effects.keyword.ScryEffect) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

ScryEffect (mage.abilities.effects.keyword.ScryEffect)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 MageObject (mage.MageObject)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 BoostSourceEffect (mage.abilities.effects.common.continuous.BoostSourceEffect)1 Card (mage.cards.Card)1 CardsImpl (mage.cards.CardsImpl)1 Permanent (mage.game.permanent.Permanent)1 Spell (mage.game.stack.Spell)1 CommanderPlaysCountWatcher (mage.watchers.common.CommanderPlaysCountWatcher)1