Search in sources :

Example 6 with EmptyCopyApplier

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

the class SakashimasWillCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetControlledCreaturePermanent();
    target.setNotTarget(true);
    if (!target.canChoose(source.getSourceId(), player.getId(), game)) {
        return false;
    }
    player.choose(outcome, target, source.getSourceId(), game);
    Permanent chosenCreature = game.getPermanent(target.getFirstTarget());
    if (chosenCreature == null) {
        return false;
    }
    for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, player.getId(), source.getSourceId(), game)) {
        if (permanent == null || permanent.getId().equals(chosenCreature.getId())) {
            continue;
        }
        game.copyPermanent(Duration.EndOfTurn, chosenCreature, permanent.getId(), source, new EmptyCopyApplier());
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) TargetPermanent(mage.target.TargetPermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 7 with EmptyCopyApplier

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

the class MizziumTransreliquatCopyAndGainAbilityEffect 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 : TargetArtifactPermanent(mage.target.common.TargetArtifactPermanent) Permanent(mage.game.permanent.Permanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier)

Example 8 with EmptyCopyApplier

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

the class ThespiansStageCopyEffect 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) {
        Permanent newPermanent = game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new EmptyCopyApplier());
        Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ThespiansStageCopyEffect(), new GenericManaCost(2));
        ability.addCost(new TapSourceCost());
        ability.addTarget(new TargetLandPermanent());
        newPermanent.addAbility(ability, source.getSourceId(), game);
        return true;
    }
    return false;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ColorlessManaAbility(mage.abilities.mana.ColorlessManaAbility) Ability(mage.abilities.Ability) TargetLandPermanent(mage.target.common.TargetLandPermanent) Permanent(mage.game.permanent.Permanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) TargetLandPermanent(mage.target.common.TargetLandPermanent) TapSourceCost(mage.abilities.costs.common.TapSourceCost)

Example 9 with EmptyCopyApplier

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

the class MirrorOfTheForebearsCopyEffect 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());
        game.addEffect(new AddCardTypeSourceEffect(Duration.EndOfTurn, CardType.ARTIFACT), source);
        return true;
    }
    return false;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) EmptyCopyApplier(mage.util.functions.EmptyCopyApplier) AddCardTypeSourceEffect(mage.abilities.effects.common.continuous.AddCardTypeSourceEffect)

Example 10 with EmptyCopyApplier

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

the class MirrorWeaveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    if (controller != null) {
        Permanent copyFromCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
        if (copyFromCreature != null) {
            filter.add(Predicates.not(new PermanentIdPredicate(copyFromCreature.getId())));
            for (Permanent copyToCreature : game.getBattlefield().getAllActivePermanents(filter, game)) {
                if (copyToCreature != null) {
                    game.copyPermanent(Duration.EndOfTurn, copyFromCreature, copyToCreature.getId(), source, new EmptyCopyApplier());
                }
            }
        }
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) 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