use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class KappaTechWreckerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterArtifactOrEnchantmentPermanent("artifact or enchantment that player controls");
filter.add(new ControllerIdPredicate(getTargetPointer().getFirst(game, source)));
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ExileTargetEffect(), false);
ability.addTarget(new TargetPermanent(filter));
return new DoWhenCostPaid(ability, new RemoveCountersSourceCost(CounterType.DEATHTOUCH.createInstance()), "Remove a deathtouch counter?").apply(game, source);
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class KarmicJusticeTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(controllerId) && game.getOpponents(this.getControllerId()).contains(game.getControllerId(event.getSourceId()))) {
MageObject mageObject = game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
if (!mageObject.isCreature(game)) {
this.getTargets().clear();
FilterPermanent filter = new FilterPermanent("target permanent that opponent controls");
filter.add(new ControllerIdPredicate(game.getControllerId(event.getSourceId())));
Target target = new TargetPermanent(filter);
this.getTargets().add(target);
return true;
}
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class LightwielderPaladinTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
Player player = game.getPlayer(event.getTargetId());
if (player != null) {
FilterPermanent filter = new FilterPermanent("black or red permanent controlled by " + player.getLogName());
filter.add(Predicates.or(new ColorPredicate(ObjectColor.BLACK), new ColorPredicate(ObjectColor.RED)));
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 PerilousPredicamentSacrificeOpponentsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<UUID> perms = new ArrayList<>();
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterArtifactCreaturePermanent filterArtifact = new FilterArtifactCreaturePermanent("an artifact creature");
filterArtifact.add(new ControllerIdPredicate(player.getId()));
FilterCreaturePermanent filterNonArtifact = new FilterCreaturePermanent("a nonartifact creature");
filterNonArtifact.add(Predicates.not(CardType.ARTIFACT.getPredicate()));
filterNonArtifact.add(new ControllerIdPredicate(player.getId()));
if (game.getBattlefield().countAll(filterArtifact, player.getId(), game) > 0) {
TargetPermanent target = new TargetPermanent(1, 1, filterArtifact, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
if (game.getBattlefield().countAll(filterNonArtifact, player.getId(), game) > 0) {
TargetPermanent target = new TargetPermanent(1, 1, filterNonArtifact, true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Sacrifice, target, source, game);
perms.addAll(target.getTargets());
}
}
}
}
for (UUID permID : perms) {
Permanent permanent = game.getPermanent(permID);
if (permanent != null) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class PolisCrusherTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
Player player = game.getPlayer(event.getTargetId());
if (player != null) {
FilterPermanent filter = new FilterPermanent("an enchantment controlled by " + player.getLogName());
filter.add(CardType.ENCHANTMENT.getPredicate());
filter.add(new ControllerIdPredicate(event.getTargetId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
}
return false;
}
Aggregations