use of mage.ObjectColor in project mage by magefree.
the class WojekSirenBoostEffect 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 WojekApothecaryEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
if (target != null) {
ObjectColor color = target.getColor(game);
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
if (permanent.getColor(game).shares(color)) {
ContinuousEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, 1);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
}
}
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class HallOfTriumphBoostControlledEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
if (color != null) {
for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) {
if (perm.getColor(game).shares(color)) {
perm.addPower(1);
perm.addToughness(1);
}
}
return true;
}
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class OpalTitanBecomesCreatureEffect method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
if (permanent != null) {
switch(layer) {
case TypeChangingEffects_4:
permanent.removeAllCardTypes(game);
permanent.addCardType(game, CardType.CREATURE);
permanent.removeAllSubTypes(game);
permanent.addSubType(game, SubType.GIANT);
break;
case AbilityAddingRemovingEffects_6:
if (game.getState().getValue("opalTitanColor" + source.getSourceId()) != null) {
for (ObjectColor color : ((ObjectColor) game.getState().getValue("opalTitanColor" + source.getSourceId())).getColors()) {
if (!permanent.getAbilities().contains(ProtectionAbility.from(color))) {
permanent.addAbility(ProtectionAbility.from(color), source.getSourceId(), game);
}
}
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
permanent.getPower().setValue(4);
permanent.getToughness().setValue(4);
}
break;
}
return true;
}
this.discard();
return false;
}
use of mage.ObjectColor in project mage by magefree.
the class PrismRingTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getPlayerId().equals(this.getControllerId())) {
Spell spell = game.getStack().getSpell(event.getTargetId());
ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
if (spell != null && color != null && spell.getColor(game).shares(color)) {
return true;
}
}
return false;
}
Aggregations