use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class SanctuaryInterveningIfTriggeredAbility method makeAndCondition.
private static Condition makeAndCondition(ObjectColor color1, ObjectColor color2) {
FilterPermanent filter1 = new FilterPermanent();
filter1.add(new ColorPredicate(color1));
Condition condition1 = new PermanentsOnTheBattlefieldCondition(filter1);
FilterPermanent filter2 = new FilterPermanent();
filter2.add(new ColorPredicate(color2));
Condition condition2 = new PermanentsOnTheBattlefieldCondition(filter2);
return new CompoundCondition(condition1, condition2);
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class SanctuaryInterveningIfTriggeredAbility method makeOrCondition.
private static Condition makeOrCondition(ObjectColor color1, ObjectColor color2) {
FilterPermanent filter = new FilterPermanent();
filter.add(Predicates.or(new ColorPredicate(color1), new ColorPredicate(color2)));
return new PermanentsOnTheBattlefieldCondition(filter);
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class EarnestFellowshipEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (permanent.getColor(game).hasColor()) {
List<ColorPredicate> colorPredicates = new ArrayList<>();
for (ObjectColor color : permanent.getColor(game).getColors()) {
colorPredicates.add(new ColorPredicate(color));
}
FilterCard filterColors = new FilterCard("its colors");
filterColors.add(Predicates.or(colorPredicates));
Ability ability = new ProtectionAbility(filterColors);
permanent.addAbility(ability, source.getSourceId(), game);
}
}
return true;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class PsychicAllergyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) {
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
filter.add(TokenPredicate.FALSE);
int damage = game.getBattlefield().countAll(filter, player.getId(), game);
player.damage(damage, source.getSourceId(), source, game);
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class EmptyShrineKannushiProtectionAbility method canTarget.
@Override
public boolean canTarget(MageObject source, Game game) {
ObjectColor color = new ObjectColor();
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controllerId)) {
ObjectColor permanentColor = permanent.getColor(game);
if (permanentColor.isColorless()) {
continue;
}
if (permanentColor.isBlack()) {
color.setBlack(true);
}
if (permanentColor.isBlue()) {
color.setBlue(true);
}
if (permanentColor.isGreen()) {
color.setGreen(true);
}
if (permanentColor.isRed()) {
color.setRed(true);
}
if (permanentColor.isWhite()) {
color.setWhite(true);
}
}
List<Predicate<MageObject>> colorPredicates = new ArrayList<>();
if (color.isBlack()) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (color.isBlue()) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (color.isGreen()) {
colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (color.isRed()) {
colorPredicates.add(new ColorPredicate(ObjectColor.RED));
}
if (color.isWhite()) {
colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
}
Filter protectionFilter = new FilterObject("the colors of permanents you control");
protectionFilter.add(Predicates.or(colorPredicates));
this.filter = protectionFilter;
return super.canTarget(source, game);
}
Aggregations