use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class JeweledSpiritEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChoiceColorOrArtifact choice = new ChoiceColorOrArtifact();
if (controller != null && controller.choose(outcome, choice, game)) {
FilterCard protectionFilter = new FilterCard();
if (choice.isArtifactSelected()) {
protectionFilter.add(CardType.ARTIFACT.getPredicate());
} else {
protectionFilter.add(new ColorPredicate(choice.getColor()));
}
protectionFilter.setMessage(choice.getChoice());
ProtectionAbility protectionAbility = new ProtectionAbility(protectionFilter);
ContinuousEffect effect = new GainAbilitySourceEffect(protectionAbility, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class SungoldSentinelEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ChoiceColor choice = new ChoiceColor(true);
player.choose(outcome, choice, game);
Ability ability = HexproofBaseAbility.getFirstFromColor(choice.getColor());
game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
game.addEffect(new CantBeBlockedByAllSourceEffect(filter, Duration.EndOfTurn), source);
return true;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class SuddenDemiseDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(outcome, choice, game)) {
final int damage = source.getManaCostsToPay().getX();
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.damage(damage, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class WardSliverGainAbilityControlledEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
if (protectionFilter == null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
if (color != null) {
protectionFilter = new FilterPermanent(color.getDescription());
protectionFilter.add(new ColorPredicate(color));
}
}
}
if (protectionFilter != null) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_ALL_SLIVERS, game)) {
perm.addAbility(new ProtectionAbility(protectionFilter), source.getSourceId(), game);
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class WashOutEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> cardsToReturn = new LinkedHashSet<>();
ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) {
ObjectColor color = choice.getColor();
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(color));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
cardsToReturn.add((Card) permanent);
}
return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
}
return false;
}
Aggregations