use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class EchoingDecayEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (targetPermanent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
if (CardUtil.haveEmptyName(targetPermanent)) {
// if no name (face down creature) only the creature itself is selected
filter.add(new PermanentIdPredicate(targetPermanent.getId()));
} else {
filter.add(new NamePredicate(targetPermanent.getName()));
}
ContinuousEffect effect = new BoostAllEffect(-2, -2, Duration.EndOfTurn, filter, false);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class ExhilaratingElocutionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent == null) {
return false;
}
permanent.addCounters(CounterType.P1P1.createInstance(2), source.getControllerId(), source, game);
FilterCreaturePermanent filterPermanent = new FilterCreaturePermanent();
filterPermanent.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(permanent, game))));
game.addEffect(new BoostControlledEffect(1, 1, Duration.EndOfTurn, filterPermanent), source);
return true;
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class InstigatorEffect 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.common.FilterCreaturePermanent in project mage by magefree.
the class KillingWaveEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int amount = (ManacostVariableValue.REGULAR).calculate(game, source, this);
if (amount > 0) {
List<Permanent> sacrifices = new LinkedList<>();
Map<UUID, Integer> lifePaidAmounts = new HashMap<>();
FilterCreaturePermanent filter = new FilterCreaturePermanent();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(filter, playerId, game);
int lifePaid = 0;
int playerLife = player.getLife();
for (Permanent creature : creatures) {
String message = "Pay " + amount + " life? If you don't, " + creature.getName() + " will be sacrificed.";
if (playerLife - amount - lifePaid >= 0 && player.chooseUse(Outcome.Neutral, message, source, game)) {
game.informPlayers(player.getLogName() + " pays " + amount + " life. They will not sacrifice " + creature.getName());
lifePaid += amount;
} else {
game.informPlayers(player.getLogName() + " will sacrifice " + creature.getName());
sacrifices.add(creature);
}
}
lifePaidAmounts.put(playerId, lifePaid);
}
}
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
int lifePaid = lifePaidAmounts.get(playerId);
if (lifePaid > 0) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.loseLife(lifePaid, game, source, false);
}
}
}
for (Permanent creature : sacrifices) {
creature.sacrifice(source, game);
}
}
return true;
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class KindredDominanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (controller != null && controller.choose(outcome, typeChoice, game)) {
game.informPlayers(controller.getLogName() + " has chosen " + typeChoice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures not of the chosen type");
filter.add(Predicates.not(SubType.byDescription(typeChoice.getChoice()).getPredicate()));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
Aggregations