Search in sources :

Example 26 with ReturnToHandTargetEffect

use of mage.abilities.effects.common.ReturnToHandTargetEffect in project mage by magefree.

the class ContemptEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent contempt = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (contempt != null) {
        Permanent attachedToPermanent = game.getPermanent(contempt.getAttachedTo());
        if (attachedToPermanent != null) {
            Effect effect = new ReturnToHandTargetEffect();
            effect.setTargetPointer(new FixedTarget(attachedToPermanent.getId(), game)).setText("return " + attachedToPermanent.getName() + " to owner's hand.");
            AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
            game.addDelayedTriggeredAbility(ability, source);
        }
        Effect effect = new ReturnToHandSourceEffect();
        AtTheEndOfCombatDelayedTriggeredAbility ability = new AtTheEndOfCombatDelayedTriggeredAbility(effect);
        game.addDelayedTriggeredAbility(ability, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Effect(mage.abilities.effects.Effect) AttachEffect(mage.abilities.effects.common.AttachEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)

Aggregations

ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)26 FixedTarget (mage.target.targetpointer.FixedTarget)21 Effect (mage.abilities.effects.Effect)19 OneShotEffect (mage.abilities.effects.OneShotEffect)18 Player (mage.players.Player)15 Permanent (mage.game.permanent.Permanent)14 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)13 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)9 Card (mage.cards.Card)9 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)6 FilterCard (mage.filter.FilterCard)5 TargetPermanent (mage.target.TargetPermanent)5 ContinuousEffect (mage.abilities.effects.ContinuousEffect)4 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)4 TargetCardInHand (mage.target.common.TargetCardInHand)4 UUID (java.util.UUID)3 Cost (mage.abilities.costs.Cost)3 ArrayList (java.util.ArrayList)2 MageObject (mage.MageObject)2 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)2