use of mage.filter.FilterPermanent 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.FilterPermanent in project mage by magefree.
the class KarrthusControlEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterPermanent();
filter.add(SubType.DRAGON.getPredicate());
List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter, game);
for (Permanent dragon : dragons) {
ContinuousEffect effect = new KarrthusControlEffect(source.getControllerId());
effect.setTargetPointer(new FixedTarget(dragon.getId(), game));
game.addEffect(effect, source);
}
for (Permanent dragon : dragons) {
dragon.untap(game);
}
return true;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class NihiloorLoseLifeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
for (UUID playerId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(playerId);
if (opponent == null) {
continue;
}
TargetPermanent target = new TargetPermanent(0, 1, filter, true);
target.withChooseHint("tapping a creature controlled by " + opponent.getName());
controller.choose(outcome, target, source.getControllerId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null || !permanent.tap(source, game)) {
continue;
}
FilterPermanent filter2 = new FilterPermanent("creature controlled by " + opponent.getName() + " with power " + permanent.getPower().getValue() + " or less");
filter2.add(new NihiloorPredicate(permanent, playerId));
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new GainControlTargetEffect(Duration.Custom, true), false, "gain control of target creature that player controls with " + "power less than or equal to the tapped creature's power for as long as you control {this}");
ability.addTarget(new TargetPermanent(filter2));
game.fireReflexiveTriggeredAbility(ability, source);
}
return true;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class NightmareUnmakingEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(comparisonType, player.getHand().size()));
return new ExileAllEffect(filter).apply(game, source);
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class OranRiefTheVastwoodEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterPermanent();
filter.add(CardType.CREATURE.getPredicate());
filter.add(new ColorPredicate(ObjectColor.GREEN));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (permanent.getTurnsOnBattlefield() == 0) {
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
return true;
}
Aggregations