Search in sources :

Example 41 with MageObjectReference

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;
}
Also used : TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) MageObjectReference(mage.MageObjectReference)

Example 42 with MageObjectReference

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));
}
Also used : MageObjectReference(mage.MageObjectReference)

Example 43 with MageObjectReference

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));
    }
}
Also used : MageObjectReference(mage.MageObjectReference) Spell(mage.game.stack.Spell)

Example 44 with MageObjectReference

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));
            }
        }
    }
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor) MageObjectReference(mage.MageObjectReference)

Example 45 with MageObjectReference

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;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) MageObjectReference(mage.MageObjectReference)

Aggregations

MageObjectReference (mage.MageObjectReference)250 Permanent (mage.game.permanent.Permanent)147 Player (mage.players.Player)76 UUID (java.util.UUID)47 Card (mage.cards.Card)45 Ability (mage.abilities.Ability)34 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)33 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)26 OneShotEffect (mage.abilities.effects.OneShotEffect)24 FilterPermanent (mage.filter.FilterPermanent)23 Game (mage.game.Game)22 Spell (mage.game.stack.Spell)21 TargetPermanent (mage.target.TargetPermanent)20 CardImpl (mage.cards.CardImpl)18 CardSetInfo (mage.cards.CardSetInfo)18 MageObject (mage.MageObject)17 Effect (mage.abilities.effects.Effect)16 HashSet (java.util.HashSet)15 mage.constants (mage.constants)14 GameEvent (mage.game.events.GameEvent)13