use of mage.ObjectColor 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.ObjectColor in project mage by magefree.
the class PrismaticWardPreventDamageEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!super.applies(event, source, game)) {
return false;
}
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
return false;
}
ObjectColor color = (ObjectColor) game.getState().getValue(permanent.getId() + "_color");
if (color == null) {
return false;
}
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject == null || !sourceObject.getColor(game).shares(color)) {
return false;
}
Permanent attachment = game.getPermanent(source.getSourceId());
if (attachment != null && attachment.getAttachedTo() != null && event.getTargetId().equals(attachment.getAttachedTo())) {
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class RallyTheRighteousBoostEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
affectedObjectList.add(new MageObjectReference(target, game));
ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) {
affectedObjectList.add(new MageObjectReference(permanent, game));
}
}
}
}
use of mage.ObjectColor 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.ObjectColor 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;
}
Aggregations