use of mage.filter.FilterPermanent in project mage by magefree.
the class DualNatureExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (creature != null) {
FilterPermanent filter = new FilterPermanent();
filter.add(TokenPredicate.TRUE);
filter.add(new NamePredicate(creature.getName()));
new ExileAllEffect(filter).apply(game, source);
return true;
}
return false;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class FarrelsMantleDamageEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent aura = getSourcePermanentOrLKI(game);
if (aura == null || !event.getTargetId().equals(aura.getAttachedTo()) || game.getPermanent(aura.getAttachedTo()) == null) {
return false;
}
MageObjectReference mor = new MageObjectReference(event.getTargetId(), game);
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(Predicates.not(new MageObjectReferencePredicate(mor)));
TargetPermanent target = new TargetPermanent(filter);
target.setTargetController(game.getControllerId(event.getTargetId()));
this.getTargets().clear();
this.addTarget(target);
this.getEffects().clear();
this.addEffect(new FarrelsMantleEffect(mor));
return true;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class FlamesOfTheRazeBoarEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.damage(4, source.getSourceId(), source, game);
if (!FerociousCondition.instance.apply(game, source)) {
return true;
}
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(permanent.getControllerId()));
filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
return new DamageAllEffect(2, filter).apply(game, source);
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class HarshMercyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Set<String> chosenTypes = new HashSet<>();
PlayerIteration: for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (player != null && !player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
continue PlayerIteration;
}
String chosenType = typeChoice.getChoice();
if (chosenType != null) {
game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType);
chosenTypes.add(chosenType);
}
}
FilterPermanent filter = new FilterCreaturePermanent("creatures");
for (String type : chosenTypes) {
filter.add(Predicates.not(SubType.byDescription(type).getPredicate()));
}
return new DestroyAllEffect(filter, true).apply(game, source);
}
return false;
}
use of mage.filter.FilterPermanent 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;
}
Aggregations