use of mage.filter.FilterObject in project mage by magefree.
the class PrismaticCircleEffect method init.
@Override
public void init(Ability source, Game game) {
FilterObject filter = targetSource.getFilter();
filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
super.init(source, game);
}
use of mage.filter.FilterObject in project mage by magefree.
the class StoryCircleEffect method init.
@Override
public void init(Ability source, Game game) {
FilterObject filter = targetSource.getFilter();
filter.add(new ColorPredicate((ObjectColor) game.getState().getValue(source.getSourceId() + "_color")));
super.init(source, game);
}
use of mage.filter.FilterObject in project mage by magefree.
the class ProtectionChosenColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
chosenColor = color;
FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
protectionFilter.add(new ColorPredicate(chosenColor));
protectionAbility = new ProtectionAbility(protectionFilter);
}
if (protectionAbility != null) {
permanent.addAbility(protectionAbility, source.getSourceId(), game);
return true;
}
}
return false;
}
use of mage.filter.FilterObject in project mage by magefree.
the class ProtectionChosenColorSourceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
chosenColor = color;
FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
protectionFilter.add(new ColorPredicate(chosenColor));
protectionAbility = new ProtectionAbility(protectionFilter);
}
if (protectionAbility != null) {
permanent.addAbility(protectionAbility, source.getSourceId(), game);
return true;
}
}
return false;
}
use of mage.filter.FilterObject in project mage by magefree.
the class ProtectionChosenColorAttachedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent attachement = game.getPermanent(source.getSourceId());
if (attachement != null && attachement.getAttachedTo() != null) {
ObjectColor color = (ObjectColor) game.getState().getValue(attachement.getId() + "_color");
if (color != null && (protectionAbility == null || !color.equals(chosenColor))) {
chosenColor = color;
FilterObject protectionFilter = new FilterObject(chosenColor.getDescription());
protectionFilter.add(new ColorPredicate(chosenColor));
protectionAbility = new ProtectionAbility(protectionFilter);
if (notRemoveItself) {
protectionAbility.setAuraIdNotToBeRemoved(source.getSourceId());
}
if (notRemoveControlled) {
protectionAbility.setDoesntRemoveControlled(true);
protectionAbility.setRemoveEquipment(false);
protectionAbility.setRemovesAuras(false);
}
}
if (protectionAbility != null) {
Permanent attachedTo = game.getPermanent(attachement.getAttachedTo());
if (attachedTo != null) {
attachedTo.addAbility(protectionAbility, source.getSourceId(), game);
}
return true;
}
}
return false;
}
Aggregations