use of mage.MageObjectReference in project mage by magefree.
the class LiegeOfTheTangleEffect method apply.
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
Permanent perm = it.next().getPermanent(game);
if (perm == null) {
it.remove();
continue;
}
if (perm.getCounters(game).getCount(CounterType.AWAKENING) < 1) {
continue;
}
switch(layer) {
case TypeChangingEffects_4:
perm.addCardType(game, CardType.CREATURE);
perm.addSubType(game, SubType.ELEMENTAL);
break;
case ColorChangingEffects_5:
perm.getColor(game).addColor(ObjectColor.GREEN);
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
perm.getPower().setValue(8);
perm.getToughness().setValue(8);
}
break;
}
}
return true;
}
use of mage.MageObjectReference in project mage by magefree.
the class NecromancyChangeAbilityEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
}
use of mage.MageObjectReference in project mage by magefree.
the class OpalTitanBecomesCreatureEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
Spell creatureSpellCast = game.getSpell(targetPointer.getFirst(game, source));
if (creatureSpellCast != null && creatureSpellCast.getColor(game).hasColor()) {
game.getState().setValue("opalTitanColor" + source.getSourceId(), creatureSpellCast.getColor(game));
}
}
use of mage.MageObjectReference 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.MageObjectReference in project mage by magefree.
the class AttackedOrBlockedSinceYourLastUpkeepWatcher method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
AttackedOrBlockedSinceYourLastUpkeepWatcher watcher = game.getState().getWatcher(AttackedOrBlockedSinceYourLastUpkeepWatcher.class);
if (permanent != null && permanent.getAttachedTo() != null && watcher != null) {
Permanent attachedTo = game.getBattlefield().getPermanent(permanent.getAttachedTo());
if (attachedTo == null) {
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
}
if (attachedTo != null) {
return watcher.attackedSinceLastUpkeep(new MageObjectReference(attachedTo.getId(), attachedTo.getZoneChangeCounter(game), game), source.getControllerId());
}
}
return false;
}
Aggregations