use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class EmberGaleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
RestrictionEffect effect = new CantBlockAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
FilterPermanent filter2 = new FilterPermanent();
filter2.add(new ControllerIdPredicate(targetPlayer.getId()));
filter2.add(Predicates.or(new ColorPredicate(ObjectColor.WHITE), new ColorPredicate(ObjectColor.BLUE)));
filter2.add(CardType.CREATURE.getPredicate());
for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter2, targetPlayer.getId(), game)) {
creature.damage(1, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class LightwielderPaladinTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && ((DamagedPlayerEvent) event).isCombatDamage()) {
Player player = game.getPlayer(event.getTargetId());
if (player != null) {
FilterPermanent filter = new FilterPermanent("black or red permanent controlled by " + player.getLogName());
filter.add(Predicates.or(new ColorPredicate(ObjectColor.BLACK), new ColorPredicate(ObjectColor.RED)));
filter.add(new ControllerIdPredicate(event.getTargetId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class PersecuteEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
ChoiceColor choice = new ChoiceColor();
if (controller == null || sourceObject == null || targetPlayer == null || !controller.choose(outcome, choice, game)) {
return false;
}
FilterCard filterCard = new FilterCard();
filterCard.add(new ColorPredicate(choice.getColor()));
targetPlayer.revealCards(source, targetPlayer.getHand(), game);
targetPlayer.discard(new CardsImpl(targetPlayer.getHand().getCards(filterCard, game)), false, source, game);
return true;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class RithTheAwakenerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
ChoiceColor choice = new ChoiceColor();
if (controller.choose(outcome, choice, game)) {
game.informPlayers(controller.getLogName() + " chooses " + choice.getColor());
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(choice.getColor()));
int cardsWithColor = game.getBattlefield().count(filter, source.getSourceId(), controller.getId(), game);
if (cardsWithColor > 0) {
new CreateTokenEffect(new SaprolingToken(), cardsWithColor).apply(game, source);
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class GainProtectionFromColorAllEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterCard protectionFilter = (FilterCard) ((ProtectionAbility) ability).getFilter();
protectionFilter.add(new ColorPredicate(choice.getColor()));
protectionFilter.setMessage(choice.getChoice());
((ProtectionAbility) ability).setFilter(protectionFilter);
return super.apply(game, source);
}
Aggregations