use of mage.filter.common.FilterLandPermanent in project mage by magefree.
the class DemonicHordesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent demonicHordes = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (controller != null && demonicHordes != null) {
StringBuilder sb = new StringBuilder(cost.getText()).append('?');
if (!sb.toString().toLowerCase(Locale.ENGLISH).startsWith("exile ") && !sb.toString().toLowerCase(Locale.ENGLISH).startsWith("return ")) {
sb.insert(0, "Pay ");
}
if (controller.chooseUse(Outcome.Benefit, sb.toString(), source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
return true;
}
}
demonicHordes.tap(source, game);
Target choiceOpponent = new TargetOpponent();
choiceOpponent.setNotTarget(true);
FilterLandPermanent filterLand = new FilterLandPermanent();
filterLand.add(new ControllerIdPredicate(source.getControllerId()));
if (controller.choose(Outcome.Neutral, choiceOpponent, source.getSourceId(), game)) {
Player opponent = game.getPlayer(choiceOpponent.getFirstTarget());
if (opponent != null) {
Target chosenLand = new TargetLandPermanent(filterLand);
chosenLand.setNotTarget(true);
if (opponent.chooseTarget(Outcome.Sacrifice, chosenLand, source, game)) {
Permanent land = game.getPermanent(chosenLand.getFirstTarget());
if (land != null) {
land.sacrifice(source, game);
}
}
}
return true;
}
}
return false;
}
use of mage.filter.common.FilterLandPermanent in project mage by magefree.
the class AnathemancerCount method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility.getFirstTarget() == null) {
return 0;
}
FilterLandPermanent filter = new FilterLandPermanent();
filter.add(Predicates.not(SuperType.BASIC.getPredicate()));
filter.add(new ControllerIdPredicate(sourceAbility.getFirstTarget()));
return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
Aggregations