use of mage.ObjectColor in project mage by magefree.
the class LeaveNoTraceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent target = game.getPermanent(targetPointer.getFirst(game, source));
if (target != null) {
ObjectColor color = target.getColor(game);
target.destroy(source, game, false);
for (Permanent p : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (p.getColor(game).shares(color)) {
p.destroy(source, game, false);
}
}
return true;
}
return false;
}
use of mage.ObjectColor 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.ObjectColor in project mage by magefree.
the class ThoughtPrisonDamageEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Spell spell = (Spell) game.getObject(event.getTargetId());
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
if (spell instanceof Spell) {
if (sourcePermanent == null) {
sourcePermanent = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD);
}
if (sourcePermanent != null && sourcePermanent.getImprinted() != null && !sourcePermanent.getImprinted().isEmpty()) {
Card imprintedCard = game.getCard(sourcePermanent.getImprinted().get(0));
if (imprintedCard != null && game.getState().getZone(imprintedCard.getId()) == Zone.EXILED) {
// Check if spell's color matches the imprinted card
ObjectColor spellColor = spell.getColor(game);
ObjectColor imprintedColor = imprintedCard.getColor(game);
boolean matches = false;
if (spellColor.shares(imprintedColor)) {
matches = true;
}
// Check if spell's CMC matches the imprinted card
int cmc = spell.getManaValue();
int imprintedCmc = imprintedCard.getManaValue();
if (cmc == imprintedCmc) {
matches = true;
}
if (matches) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return matches;
}
}
}
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class VolrathsLaboratoryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
SubType subType = ChooseCreatureTypeEffect.getChosenCreatureType(source.getSourceId(), game);
Token token = new VolrathsLaboratoryToken(color, subType);
return token.putOntoBattlefield(1, game, source, source.getControllerId());
}
use of mage.ObjectColor in project mage by magefree.
the class ZombieBoaTriggeredAbility method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ChoiceColor choice = new ChoiceColor();
if (player.choose(outcome, choice, game)) {
ObjectColor color = choice.getColor();
game.informPlayers(player.getLogName() + " chooses " + color);
game.addDelayedTriggeredAbility(new ZombieBoaTriggeredAbility(color), source);
return true;
}
return false;
}
Aggregations