Search in sources :

Example 1 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class HeartPiercerManticoreSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
    if (!controller.choose(outcome, target, source.getSourceId(), game)) {
        return false;
    }
    Permanent toSacrifice = game.getPermanent(target.getFirstTarget());
    if (toSacrifice == null) {
        return false;
    }
    int power = toSacrifice.getPower().getValue();
    if (!toSacrifice.sacrifice(source, game)) {
        return false;
    }
    ReflexiveTriggeredAbility trigger = new ReflexiveTriggeredAbility(new DamageTargetEffect(power), false, "{this} deals damage equal to that creature's power to any target.");
    trigger.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(trigger, source);
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetAnyTarget(mage.target.common.TargetAnyTarget) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Example 2 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class RemnantOfTheRisingStarEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    ManaCosts<ManaCost> cost = new ManaCostsImpl<>("{X}");
    if (player == null || !player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", source, game)) {
        return false;
    }
    int xValue = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
    cost.add(new GenericManaCost(xValue));
    if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
        return false;
    }
    Permanent permanent = (Permanent) getValue("permanentEnteringBattlefield");
    if (permanent == null) {
        return false;
    }
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance(xValue)).setTargetPointer(new FixedTarget(permanent, game)), false), source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) FilterPermanent(mage.filter.FilterPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) Hint(mage.abilities.hint.Hint) ValueHint(mage.abilities.hint.ValueHint)

Example 3 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class ValentinDeanOfTheVeinEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ((ZoneChangeEvent) event).setToZone(Zone.EXILED);
    game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new DoIfCostPaid(new CreateTokenEffect(new Pest11GainLifeToken()), new GenericManaCost(2)), false, "you may pay {2}. If you do, create a 1/1 black and green " + "Pest creature token with \"When this creature dies, you gain 1 life.\""), source);
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) DoIfCostPaid(mage.abilities.effects.common.DoIfCostPaid) Pest11GainLifeToken(mage.game.permanent.token.Pest11GainLifeToken) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 4 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class WallOfStolenIdentityCopyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent == null) {
        permanent = game.getPermanentEntering(source.getSourceId());
    }
    final Permanent sourcePermanent = permanent;
    if (controller == null || sourcePermanent == null) {
        return false;
    }
    Target target = new TargetPermanent(new FilterCreaturePermanent("target creature (you copy from)"));
    target.setRequired(true);
    if (source instanceof SimpleStaticAbility) {
        target = new TargetPermanent(new FilterCreaturePermanent("creature (you copy from)"));
        target.setRequired(false);
        target.setNotTarget(true);
    }
    if (!target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
        return false;
    }
    controller.choose(Outcome.Copy, target, source.getSourceId(), game);
    Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
    if (copyFromPermanent == null) {
        return false;
    }
    game.copyPermanent(copyFromPermanent, sourcePermanent.getId(), source, new CopyApplier() {

        @Override
        public boolean apply(Game game, MageObject blueprint, Ability source, UUID copyToObjectId) {
            blueprint.addSubType(SubType.WALL);
            blueprint.getAbilities().add(DefenderAbility.getInstance());
            return true;
        }
    });
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new TapTargetEffect(), false, "tap the copied creature " + "and it doesn't untap during its controller's untap step for as long as you control {this}");
    ability.addEffect(new DontUntapInControllersUntapStepTargetEffect(Duration.WhileControlled));
    ability.getEffects().setTargetPointer(new FixedTarget(copyFromPermanent, game));
    game.fireReflexiveTriggeredAbility(ability, source);
    return true;
}
Also used : ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) DefenderAbility(mage.abilities.keyword.DefenderAbility) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) MageObject(mage.MageObject) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Game(mage.game.Game) CopyApplier(mage.util.functions.CopyApplier) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TapTargetEffect(mage.abilities.effects.common.TapTargetEffect) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID) DontUntapInControllersUntapStepTargetEffect(mage.abilities.effects.common.DontUntapInControllersUntapStepTargetEffect)

Example 5 with ReflexiveTriggeredAbility

use of mage.abilities.common.delayed.ReflexiveTriggeredAbility in project mage by magefree.

the class CemeteryDesecratorRemoveCountersEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
        target.setNotTarget(true);
        controller.choose(outcome, target, source.getSourceId(), game);
        Card card = game.getCard(target.getFirstTarget());
        if (card != null) {
            int manaValue = card.getManaValue();
            if (controller.moveCards(card, Zone.EXILED, source, game)) {
                ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new CemeteryDesecratorRemoveCountersEffect(manaValue), false, triggerText);
                ability.addTarget(new TargetPermanent());
                Mode mode = new Mode(new BoostTargetEffect(-manaValue, -manaValue, Duration.EndOfTurn).setText("Target creature an opponent controls gets -X/-X until end of turn, where X is the mana value of the exiled card"));
                mode.addTarget(new TargetOpponentsCreaturePermanent());
                ability.addMode(mode);
                game.fireReflexiveTriggeredAbility(ability, source);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Mode(mage.abilities.Mode) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetPermanent(mage.target.TargetPermanent) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Aggregations

ReflexiveTriggeredAbility (mage.abilities.common.delayed.ReflexiveTriggeredAbility)37 Player (mage.players.Player)23 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)15 Permanent (mage.game.permanent.Permanent)13 TargetPermanent (mage.target.TargetPermanent)12 TargetAnyTarget (mage.target.common.TargetAnyTarget)11 UUID (java.util.UUID)6 Card (mage.cards.Card)6 FilterPermanent (mage.filter.FilterPermanent)6 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)5 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)4 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)4 CreateTokenEffect (mage.abilities.effects.common.CreateTokenEffect)3 DoWhenCostPaid (mage.abilities.effects.common.DoWhenCostPaid)3 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)3 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)3 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)3 FixedTarget (mage.target.targetpointer.FixedTarget)3 Mode (mage.abilities.Mode)2 ManaCosts (mage.abilities.costs.mana.ManaCosts)2