Search in sources :

Example 1 with PlayAdditionalLandsControllerEffect

use of mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect in project mage by magefree.

the class NahirisLithoformingSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || source.getManaCostsToPay().getX() == 0) {
        return false;
    }
    int landCount = game.getBattlefield().count(StaticFilters.FILTER_CONTROLLED_LAND_SHORT_TEXT, source.getSourceId(), source.getControllerId(), game);
    landCount = Math.min(source.getManaCostsToPay().getX(), landCount);
    TargetPermanent target = new TargetPermanent(landCount, landCount, StaticFilters.FILTER_CONTROLLED_LAND_SHORT_TEXT, true);
    player.choose(outcome, target, source.getSourceId(), game);
    int counter = 0;
    for (UUID permanentId : target.getTargets()) {
        Permanent permanent = game.getPermanent(permanentId);
        if (permanent != null && permanent.sacrifice(source, game)) {
            counter++;
        }
    }
    player.drawCards(counter, source, game);
    game.addEffect(new PlayAdditionalLandsControllerEffect(source.getManaCostsToPay().getX(), Duration.EndOfTurn), source);
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) PlayAdditionalLandsControllerEffect(mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Example 2 with PlayAdditionalLandsControllerEffect

use of mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect in project mage by magefree.

the class EscapeToTheWildsMayPlayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 5));
    Card sourceCard = game.getCard(source.getSourceId());
    controller.moveCards(cards, Zone.EXILED, source, game);
    cards.getCards(game).stream().forEach(card -> {
        ContinuousEffect effect = new EscapeToTheWildsMayPlayEffect();
        effect.setTargetPointer(new FixedTarget(card.getId(), game));
        game.addEffect(effect, source);
    });
    game.addEffect(new PlayAdditionalLandsControllerEffect(1, Duration.EndOfTurn), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) PlayAdditionalLandsControllerEffect(mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Aggregations

PlayAdditionalLandsControllerEffect (mage.abilities.effects.common.continuous.PlayAdditionalLandsControllerEffect)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Permanent (mage.game.permanent.Permanent)1 TargetPermanent (mage.target.TargetPermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1