Search in sources :

Example 16 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class InfiniteReflectionEntersBattlefieldEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    MageObject toCopyToObject = ((EntersTheBattlefieldEvent) event).getTarget();
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent != null && toCopyToObject != null && sourcePermanent.getAttachedTo() != null) {
        Permanent toCopyFromPermanent = game.getPermanent(sourcePermanent.getAttachedTo());
        if (toCopyFromPermanent != null) {
            game.copyPermanent(toCopyFromPermanent, toCopyToObject.getId(), source, new EmptyCopyApplier());
        }
    }
    return false;
}
Also used : EntersTheBattlefieldEvent(mage.game.events.EntersTheBattlefieldEvent) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) MageObject(mage.MageObject)

Example 17 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class OkoTheTricksterCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Permanent copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (sourcePermanent == null || copyFromPermanent == null) {
        return false;
    }
    game.copyPermanent(Duration.EndOfTurn, copyFromPermanent, sourcePermanent.getId(), source, new EmptyCopyApplier());
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Example 18 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class RenegadeDoppelgangerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (targetCreature == null || permanent == null) {
        return false;
    }
    game.copyPermanent(Duration.EndOfTurn, targetCreature, permanent.getId(), source, new EmptyCopyApplier());
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Example 19 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class TilonallisSkinshifterCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Permanent copyFromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (sourcePermanent != null && copyFromPermanent != null) {
        game.copyPermanent(Duration.EndOfTurn, copyFromPermanent, sourcePermanent.getId(), source, new EmptyCopyApplier());
        return true;
    }
    return false;
}
Also used : Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Example 20 with EmptyCopyApplier

use of mage.util.functions.EmptyCopyApplier in project mage by magefree.

the class AbsorbIdentityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent copyFrom = game.getPermanentOrLKIBattlefield(source.getFirstTarget());
    if (controller == null || copyFrom == null) {
        return false;
    }
    if (controller.chooseUse(outcome, "Have Shapeshifters you control become copies of " + copyFrom.getLogName() + " until end of turn?", source, game)) {
        FilterCreaturePermanent filter = new FilterCreaturePermanent("shapeshifter");
        filter.add(SubType.SHAPESHIFTER.getPredicate());
        for (Permanent copyTo : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
            game.copyPermanent(Duration.EndOfTurn, copyFrom, copyTo.getId(), source, new EmptyCopyApplier());
        }
    }
    return true;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Aggregations

Permanent (mage.game.permanent.Permanent)20 EmptyCopyApplier (mage.util.functions.EmptyCopyApplier)20 TargetPermanent (mage.target.TargetPermanent)9 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)7 Player (mage.players.Player)6 FilterPermanent (mage.filter.FilterPermanent)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 MageObject (mage.MageObject)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Ability (mage.abilities.Ability)2 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)2 EmptyToken (mage.game.permanent.token.EmptyToken)2 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)2 UUID (java.util.UUID)1 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 DiesCreatureTriggeredAbility (mage.abilities.common.DiesCreatureTriggeredAbility)1 EntersBattlefieldAllTriggeredAbility (mage.abilities.common.EntersBattlefieldAllTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1