use of mage.filter.common.FilterNonlandPermanent in project mage by magefree.
the class BladegriffPrototypeAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(getControllerId());
if (player == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterPermanent filter = new FilterNonlandPermanent("nonland permanent controlled by an opponent of " + player.getName());
filter.add(Predicates.or(game.getOpponents(getControllerId()).stream().map(ControllerIdPredicate::new).collect(Collectors.toSet())));
TargetPermanent target = new TargetPermanent(filter);
target.setTargetController(event.getPlayerId());
this.getTargets().clear();
this.addTarget(target);
return true;
}
use of mage.filter.common.FilterNonlandPermanent in project mage by magefree.
the class ScalelardReckonerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
Permanent creature = game.getPermanent(event.getTargetId());
if (creature != null && filter.match(creature, getSourceId(), getControllerId(), game)) {
FilterNonlandPermanent filter = new FilterNonlandPermanent("nonland permanent that player controls");
filter.add(new ControllerIdPredicate(event.getPlayerId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
}
return false;
}
use of mage.filter.common.FilterNonlandPermanent in project mage by magefree.
the class SteelHellkiteWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
SteelHellkiteWatcher watcher = game.getState().getWatcher(SteelHellkiteWatcher.class);
if (watcher == null || watcher.getDamagedPlayers(source.getSourceId()).isEmpty()) {
return false;
}
Set<Predicate<Permanent>> predicateSet = new HashSet<>();
for (UUID playerId : watcher.getDamagedPlayers(source.getSourceId())) {
predicateSet.add(new ControllerIdPredicate(playerId));
}
FilterPermanent filter = new FilterNonlandPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, source.getManaCostsToPay().getX()));
filter.add(Predicates.or(predicateSet));
return new DestroyAllEffect(filter).apply(game, source);
}
use of mage.filter.common.FilterNonlandPermanent in project mage by magefree.
the class IntellectualOfferingUntapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Target target = new TargetOpponent(true);
target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterNonlandPermanent(), player.getId(), game)) {
permanent.untap(game);
}
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent != null) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterNonlandPermanent(), opponent.getId(), game)) {
permanent.untap(game);
}
return true;
}
}
return false;
}
use of mage.filter.common.FilterNonlandPermanent in project mage by magefree.
the class TheBattleOfYavinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player opponent = game.getPlayer(source.getTargets().getFirstTarget());
if (opponent == null) {
return false;
}
int amount = (ManacostVariableValue.REGULAR).calculate(game, source, this);
if (amount > 0) {
LinkedList<Permanent> sacrifices = new LinkedList<>();
FilterNonlandPermanent filter = new FilterNonlandPermanent();
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, opponent.getId(), game);
int lifePaid = 0;
int playerLife = opponent.getLife();
for (Permanent permanent : permanents) {
String message = "Pay " + amount + " life? If you don't, " + permanent.getName() + " will be sacrificed.";
if (playerLife - amount - lifePaid >= 0 && opponent.chooseUse(Outcome.Neutral, message, source, game)) {
game.informPlayers(opponent.getLogName() + " pays " + amount + " life. They will not sacrifice " + permanent.getName());
lifePaid += amount;
} else {
game.informPlayers(opponent.getLogName() + " will sacrifice " + permanent.getName());
sacrifices.add(permanent);
}
}
if (lifePaid > 0) {
Player player = game.getPlayer(opponent.getId());
if (player != null) {
player.loseLife(lifePaid, game, source, false);
}
}
for (Permanent permanent : sacrifices) {
permanent.sacrifice(source, game);
}
}
return true;
}
Aggregations