use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class AnHavvaConstableEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("green creatures");
filter.add(new ColorPredicate(ObjectColor.GREEN));
int number = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
mageObject.getToughness().setValue(number + 1);
return true;
}
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class ChandraAblazeEffect5 method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
FilterCard filter = new FilterCard("red instant or sorcery card from your graveyard to play");
filter.add(new ColorPredicate(ObjectColor.RED));
filter.add(Predicates.or(CardType.INSTANT.getPredicate(), CardType.SORCERY.getPredicate()));
String message = "Play red instant or sorcery card from your graveyard without paying its mana cost?";
Set<Card> cards = player.getGraveyard().getCards(filter, game);
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
while (!cards.isEmpty() && player.chooseUse(outcome, message, source, game)) {
target.clearChosen();
if (player.choose(outcome, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
player.cast(player.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
cards.remove(card);
}
}
}
return true;
}
return false;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class NightshadeAssassinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(ObjectColor.BLACK));
int blackCards = controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game);
game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards.");
if (cardsToReveal > 0) {
TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter);
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
controller.revealCards(sourceObject.getIdName(), new CardsImpl(target.getTargets()), game);
int unboost = target.getTargets().size() * -1;
ContinuousEffect effect = new BoostTargetEffect(unboost, unboost, Duration.EndOfTurn);
effect.setTargetPointer(getTargetPointer());
game.addEffect(effect, source);
}
}
return true;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class OranRiefTheVastwoodEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterPermanent();
filter.add(CardType.CREATURE.getPredicate());
filter.add(new ColorPredicate(ObjectColor.GREEN));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (permanent.getTurnsOnBattlefield() == 0) {
permanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
}
}
return true;
}
use of mage.filter.predicate.mageobject.ColorPredicate in project mage by magefree.
the class SearingRaysEffect 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) && choice.getColor() != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent(choice.getColor().getDescription() + " creatures");
filter.add(new ColorPredicate(choice.getColor()));
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
int amount = game.getBattlefield().countAll(filter, playerId, game);
if (amount > 0) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount, source.getSourceId(), source, game);
}
}
}
return true;
}
return false;
}
Aggregations