Search in sources :

Example 6 with FilterControlledArtifactPermanent

use of mage.filter.common.FilterControlledArtifactPermanent in project mage by magefree.

the class DarettiSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Target target = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true);
    if (!target.canChoose(source.getSourceId(), controller.getId(), game) || !controller.chooseTarget(outcome, target, source, game)) {
        return true;
    }
    Permanent artifact = game.getPermanent(target.getFirstTarget());
    if (artifact == null || !artifact.sacrifice(source, game)) {
        return true;
    }
    Card card = game.getCard(getTargetPointer().getFirst(game, source));
    return card == null || controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) Target(mage.target.Target) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) FilterControlledArtifactPermanent(mage.filter.common.FilterControlledArtifactPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Card(mage.cards.Card) FilterArtifactCard(mage.filter.common.FilterArtifactCard)

Aggregations

FilterControlledArtifactPermanent (mage.filter.common.FilterControlledArtifactPermanent)6 Player (mage.players.Player)5 Permanent (mage.game.permanent.Permanent)4 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)4 Card (mage.cards.Card)3 Target (mage.target.Target)3 UUID (java.util.UUID)2 FilterArtifactCard (mage.filter.common.FilterArtifactCard)2 ArrayList (java.util.ArrayList)1 Cost (mage.abilities.costs.Cost)1 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)1 Counter (mage.counters.Counter)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 FilterControlledEnchantmentPermanent (mage.filter.common.FilterControlledEnchantmentPermanent)1 FilterControlledLandPermanent (mage.filter.common.FilterControlledLandPermanent)1 ManaValuePredicate (mage.filter.predicate.mageobject.ManaValuePredicate)1 TargetArtifactPermanent (mage.target.common.TargetArtifactPermanent)1