use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class SamiteElderEffect method apply.
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(source.getFirstTarget());
if (target != null) {
for (ObjectColor color : target.getColor(game).getColors()) {
FilterCard filter = new FilterCard(color.getDescription());
filter.add(new ColorPredicate(color));
game.addEffect(new GainAbilityControlledEffect(new ProtectionAbility(filter), Duration.EndOfTurn, new FilterControlledCreaturePermanent()), source);
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class ConvokeEffect method addSpecialAction.
@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && game.getBattlefield().containsControlled(filterUntapped, source, game, 1)) {
if (source.getAbilityType() == AbilityType.SPELL) {
SpecialAction specialAction = new ConvokeSpecialAction(unpaid, this);
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
// create filter for possible creatures to tap
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(TappedPredicate.UNTAPPED);
if (unpaid.getMana().getGeneric() == 0) {
List<ColorPredicate> colorPredicates = new ArrayList<>();
if (unpaid.getMana().getBlack() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
}
if (unpaid.getMana().getBlue() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
}
if (unpaid.getMana().getRed() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.RED));
}
if (unpaid.getMana().getGreen() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
}
if (unpaid.getMana().getWhite() > 0) {
colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
}
filter.add(Predicates.or(colorPredicates));
}
Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
target.setTargetName("tap creature card as convoke's pay");
specialAction.addTarget(target);
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);
}
}
}
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class DromarTheBanisherEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
if (player.choose(outcome, choice, game)) {
game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
return true;
}
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class ScryingGlassEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetOpponent = game.getPlayer(source.getFirstTarget());
ChoiceColor color = new ChoiceColor();
int amount = 0;
if (controller != null && targetOpponent != null) {
amount = controller.getAmount(1, Integer.MAX_VALUE, "Choose a number", game);
controller.choose(Outcome.Discard, color, game);
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(color.getColor()));
targetOpponent.revealCards(source, targetOpponent.getHand(), game);
if (targetOpponent.getHand().count(filter, game) == amount) {
game.informPlayers(controller.getLogName() + " has chosen the exact number and color of the revealed cards from " + targetOpponent.getName() + "'s hand. They draw a card.");
controller.drawCards(1, source, game);
return true;
} else {
game.informPlayers(controller.getLogName() + " has chosen incorrectly and will not draw a card.");
}
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class AnHavvaInnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("green creatures");
filter.add(new ColorPredicate(ObjectColor.GREEN));
int greenCreatures = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
player.gainLife(greenCreatures + 1, game, source);
}
return true;
}
Aggregations