use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class CardSelector method buildFilter.
private FilterCard buildFilter() {
FilterCard filter = new FilterCard();
String name = jTextFieldSearch.getText().trim();
filter.add(new CardTextPredicate(name, chkNames.isSelected(), chkTypes.isSelected(), chkRules.isSelected(), chkUnique.isSelected()));
if (limited) {
List<Predicate<MageObject>> predicates = new ArrayList<>();
if (this.tbGreen.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (this.tbRed.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.RED));
}
if (this.tbBlack.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (this.tbBlue.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (this.tbWhite.isSelected()) {
predicates.add(new ColorPredicate(ObjectColor.WHITE));
}
if (this.tbColorless.isSelected()) {
predicates.add(ColorlessPredicate.instance);
}
filter.add(Predicates.or(predicates));
predicates.clear();
if (this.tbLand.isSelected()) {
predicates.add(CardType.LAND.getPredicate());
}
if (this.tbArifiacts.isSelected()) {
predicates.add(CardType.ARTIFACT.getPredicate());
}
if (this.tbCreatures.isSelected()) {
predicates.add(CardType.CREATURE.getPredicate());
}
if (this.tbEnchantments.isSelected()) {
predicates.add(CardType.ENCHANTMENT.getPredicate());
}
if (this.tbInstants.isSelected()) {
predicates.add(CardType.INSTANT.getPredicate());
}
if (this.tbSorceries.isSelected()) {
predicates.add(CardType.SORCERY.getPredicate());
}
if (this.tbPlaneswalkers.isSelected()) {
predicates.add(CardType.PLANESWALKER.getPredicate());
}
filter.add(Predicates.or(predicates));
List<String> filteredSets = getFilteredSets();
if (!filteredSets.isEmpty()) {
List<Predicate<Card>> expansionPredicates = new ArrayList<>();
for (String setCode : filteredSets) {
expansionPredicates.add(new ExpansionSetPredicate(setCode));
}
filter.add(Predicates.or(expansionPredicates));
}
}
return filter;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class FaithsShieldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (controller != null && mageObject != null) {
if (FatefulHourCondition.instance.apply(game, source)) {
ChoiceColor choice = new ChoiceColor();
if (!controller.choose(Outcome.Protect, choice, game)) {
return false;
}
if (choice.getColor() != null) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen " + choice.getChoice());
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(choice.getColor()));
filter.setMessage(choice.getChoice());
Ability ability = new ProtectionAbility(filter);
game.addEffect(new GainAbilityControlledEffect(ability, Duration.EndOfTurn), source);
game.addEffect(new GainAbilityControllerEffect(ability, Duration.EndOfTurn), source);
return true;
}
} else {
game.addEffect(new GainProtectionFromColorTargetEffect(Duration.EndOfTurn), source);
return true;
}
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class JihadOpponentCondition method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
UUID chosenOpponent = (UUID) game.getState().getValue(getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(getSourceId() + "_color")));
filter.add(TokenPredicate.FALSE);
return game.getBattlefield().countAll(filter, chosenOpponent, game) == 0;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class JihadOpponentCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
UUID chosenOpponent = (UUID) game.getState().getValue(source.getSourceId().toString() + ChooseOpponentEffect.VALUE_KEY);
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
filter.add(TokenPredicate.FALSE);
return game.getBattlefield().countAll(filter, chosenOpponent, game) > 0;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class NoxiousVaporsEffect method chooseCardForColor.
private void chooseCardForColor(ObjectColor color, Set<Card> chosenCards, Player player, Game game, Ability source) {
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(color));
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
chosenCards.add(card);
}
}
}
Aggregations