use of mage.ObjectColor in project mage by magefree.
the class InvokePrejudiceEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) {
Spell spell = (Spell) game.getObject(event.getTargetId());
if (spell != null && spell.isCreature(game)) {
boolean creatureSharesAColor = false;
ObjectColor spellColor = spell.getColor(game);
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterControlledCreaturePermanent(), getControllerId(), game)) {
if (spellColor.shares(permanent.getColor(game))) {
creatureSharesAColor = true;
break;
}
}
if (!creatureSharesAColor) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
}
return true;
}
}
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class IonaShieldOfEmeriaReplacementEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
// spell is not on the stack yet, so we have to check the card
Card card = game.getCard(event.getSourceId());
if (chosenColor != null && card != null && card.getColor(game).contains(chosenColor)) {
return true;
}
}
return false;
}
use of mage.ObjectColor 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.ObjectColor 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.ObjectColor in project mage by magefree.
the class ParadisePlumeSpellCastTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
if (color != null) {
FilterSpell filter = new FilterSpell();
filter.add(new ColorPredicate(color));
Spell spell = game.getStack().getSpell(event.getTargetId());
return (spell != null && filter.match(spell, getSourceId(), getControllerId(), game));
}
return false;
}
Aggregations