use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class ParadisePlumeSpellCastTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
if (color != null) {
FilterSpell filter = new FilterSpell();
filter.add(new ColorPredicate(color));
Spell spell = game.getStack().getSpell(event.getTargetId());
return (spell != null && filter.match(spell, getSourceId(), getControllerId(), game));
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class ParasiticStrixTriggeredAbility method checkInterveningIfClause.
@Override
public boolean checkInterveningIfClause(Game game) {
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(ObjectColor.BLACK));
if (game.getBattlefield().countAll(filter, this.controllerId, game) >= 1) {
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class ThroatSlitterTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedPlayerEvent) event).isCombatDamage() && event.getSourceId().equals(sourceId)) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("nonblack creature that player controls");
filter.add(new ControllerIdPredicate(event.getPlayerId()));
filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
filter.setMessage("nonblack creature controlled by " + game.getPlayer(event.getTargetId()).getLogName());
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 TrevaTheRenewerEffect 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 GainLifeEffect(cardsWithColor).apply(game, source);
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class GainProtectionFromColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (creature != null) {
FilterCard protectionFilter = (FilterCard) ((ProtectionAbility) ability).getFilter();
protectionFilter.add(new ColorPredicate(choice.getColor()));
protectionFilter.setMessage(choice.getChoice());
((ProtectionAbility) ability).setFilter(protectionFilter);
creature.addAbility(ability, source.getSourceId(), game);
return true;
}
return false;
}
Aggregations