Search in sources :

Example 6 with ReturnToHandSourceEffect

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

the class WildWurmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        if (controller.flipCoin(source, game, true)) {
            return true;
        } else {
            new ReturnToHandSourceEffect().apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Permanent(mage.game.permanent.Permanent)

Example 7 with ReturnToHandSourceEffect

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

the class ScoriaWurmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        if (controller.flipCoin(source, game, true)) {
            return true;
        } else {
            new ReturnToHandSourceEffect().apply(game, source);
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ReturnToHandSourceEffect(mage.abilities.effects.common.ReturnToHandSourceEffect) Permanent(mage.game.permanent.Permanent)

Example 8 with ReturnToHandSourceEffect

use of mage.abilities.effects.common.ReturnToHandSourceEffect 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

ReturnToHandSourceEffect (mage.abilities.effects.common.ReturnToHandSourceEffect)8 Player (mage.players.Player)6 Permanent (mage.game.permanent.Permanent)5 FilterCreatureCard (mage.filter.common.FilterCreatureCard)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 MageObject (mage.MageObject)1 Ability (mage.abilities.Ability)1 BeginningOfEndStepTriggeredAbility (mage.abilities.common.BeginningOfEndStepTriggeredAbility)1 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 AttachEffect (mage.abilities.effects.common.AttachEffect)1 CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)1 ExileSourceEffect (mage.abilities.effects.common.ExileSourceEffect)1 PutCardFromHandOntoBattlefieldEffect (mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect)1 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)1