use of mage.filter.FilterPermanent in project mage by magefree.
the class CelestialKirinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = game.getSpellOrLKIStack(this.getTargetPointer().getFirst(game, source));
if (spell != null) {
int cmc = spell.getManaValue();
FilterPermanent filter = new FilterPermanent();
filter.add(new ManaValuePredicate(ComparisonType.EQUAL_TO, cmc));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class CephalidConstableTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
FilterPermanent filter = new FilterPermanent("permanent" + (event.getAmount() > 1 ? "s" : "") + " damaged player control");
filter.add(new ControllerIdPredicate(event.getPlayerId()));
Target target = new TargetPermanent(0, event.getAmount(), filter, false);
this.getTargets().clear();
this.getTargets().add(target);
return true;
}
return false;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class DoomForetoldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(game.getActivePlayerId());
if (controller == null || player == null) {
return false;
}
FilterPermanent filter2 = filter.copy();
filter2.add(new ControllerIdPredicate(player.getId()));
if (game.getBattlefield().contains(filter2, source, game, 1)) {
TargetPermanent target = new TargetPermanent(filter2);
target.setNotTarget(true);
if (player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null && permanent.sacrifice(source, game)) {
return true;
}
}
}
player.discard(1, false, false, source, game);
player.loseLife(2, game, source, false);
controller.drawCards(1, source, game);
controller.gainLife(2, game, source);
effect1.apply(game, source);
effect2.apply(game, source);
return true;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class EngulfTheShoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int islands = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
FilterPermanent creatureFilter = new FilterCreaturePermanent();
creatureFilter.add(new ToughnessPredicate(ComparisonType.FEWER_THAN, islands + 1));
Set<Card> cardsToHand = new HashSet<>();
for (Permanent permanent : game.getBattlefield().getActivePermanents(creatureFilter, source.getControllerId(), source.getSourceId(), game)) {
cardsToHand.add(permanent);
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
return true;
}
return false;
}
use of mage.filter.FilterPermanent in project mage by magefree.
the class JolraelEmpressOfBeastsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
FilterPermanent filter = new FilterLandPermanent();
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
game.addEffect(new BecomesCreatureAllEffect(new CreatureToken(3, 3), "lands", filter, Duration.EndOfTurn, false), source);
return true;
}
return false;
}
Aggregations