use of mage.filter.predicate.permanent.ControllerIdPredicate 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.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class SimoonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(player.getId()));
List<Permanent> creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent creature : creatures) {
creature.damage(1, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class SparkMageTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.getTargets().add(new TargetCreaturePermanent(filter));
return true;
}
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate 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.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class ThoughtsOfRuinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = controller.getHand().size();
if (amount > 0) {
List<Permanent> permanentsToSacrifice = new ArrayList<>();
// select all lands to sacrifice
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int lands = game.getState().getBattlefield().countAll(filter, playerId, game);
if (amount >= lands) {
permanentsToSacrifice.addAll(game.getState().getBattlefield().getAllActivePermanents(filter, playerId, game));
} else {
FilterLandPermanent playerFilter = filter.copy();
playerFilter.add(new ControllerIdPredicate(playerId));
Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
player.choose(outcome, target, source.getSourceId(), game);
for (UUID landId : target.getTargets()) {
Permanent permanent = game.getPermanent(landId);
if (permanent != null) {
permanentsToSacrifice.add(permanent);
}
}
}
}
}
// sacrifice all lands
for (Permanent permanent : permanentsToSacrifice) {
permanent.sacrifice(source, game);
}
}
}
return false;
}
Aggregations