use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class FallOfTheImpostorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(source.getFirstTarget());
if (controller != null && opponent != null) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, opponent.getId(), game);
Integer maxPower = null;
for (Permanent permanent : permanents) {
if (permanent != null) {
int power = permanent.getPower().getValue();
if (maxPower == null || power > maxPower) {
maxPower = power;
}
}
}
if (maxPower != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(opponent.getId()));
filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, maxPower));
TargetCreaturePermanent target = new TargetCreaturePermanent(1, 1, filter, true);
controller.chooseTarget(outcome, target, source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
controller.moveCardsToExile(permanent, source, game, true, null, null);
return true;
}
}
}
return false;
}
use of mage.filter.common.FilterCreaturePermanent 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.common.FilterCreaturePermanent in project mage by magefree.
the class GraspOfTheHieromancerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getCombat().getAttackers().contains(getSourceId())) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
if (defendingPlayerId != null) {
this.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature defending player controls");
UUID defenderId = game.getCombat().getDefenderId(getSourceId());
filter.add(new ControllerIdPredicate(defenderId));
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
this.addTarget(target);
return true;
}
}
return false;
}
use of mage.filter.common.FilterCreaturePermanent in project mage by magefree.
the class GrandMoffTarkinEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(controllerId).contains(event.getPlayerId())) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null) {
this.getTargets().clear();
FilterCreaturePermanent filter = new FilterCreaturePermanent("target creature that player controls");
filter.add(new ControllerIdPredicate(event.getPlayerId()));
TargetPermanent target = new TargetPermanent(filter);
this.addTarget(target);
return true;
}
}
return false;
}
use of mage.filter.common.FilterCreaturePermanent 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;
}
Aggregations