use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class InciteWarMustAttackEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(player.getId()));
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class KeldonFirebombersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> landsToSacrifice = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int amount = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size() - 3;
if (amount > 0) {
FilterLandPermanent playerFilter = filter.copy();
playerFilter.add(new ControllerIdPredicate(playerId));
Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
player.choose(outcome.Sacrifice, target, source.getSourceId(), game);
for (UUID landId : target.getTargets()) {
Permanent land = game.getPermanent(landId);
if (land != null) {
landsToSacrifice.add(land);
}
}
}
}
}
for (Permanent land : landsToSacrifice) {
land.sacrifice(source, game);
}
return true;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class LatullasOrdersTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (event.getSourceId().equals(enchantment.getAttachedTo()) && ((DamagedPlayerEvent) event).isCombatDamage()) {
Player player = game.getPlayer(event.getTargetId());
if (player != null) {
FilterPermanent filter = new FilterPermanent("an artifact controlled by " + player.getLogName());
filter.add(CardType.ARTIFACT.getPredicate());
filter.add(new ControllerIdPredicate(event.getTargetId()));
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 LavalancheEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
if (targetPlayer == null) {
return false;
}
targetPlayer.damage(amount.calculate(game, source, this), source.getSourceId(), source, game);
FilterPermanent filter = new FilterPermanent("and each creature that player or that planeswalker's controller controls");
filter.add(CardType.CREATURE.getPredicate());
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
permanent.damage(amount.calculate(game, source, this), source.getSourceId(), source, game, false, true);
}
return true;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class LordOfShatterskullPassEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
if (defenderId != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(defenderId));
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
for (Permanent permanent : permanents) {
permanent.damage(6, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
Aggregations