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;
}
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;
}
Aggregations