Search in sources :

Example 16 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class StanggExileTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
    if (sourceObject != null) {
        CreateTokenEffect effect = new CreateTokenEffect(new StanggTwinToken());
        effect.apply(game, source);
        game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
        for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
            Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + sourceObject.getName());
            sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
            LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
            ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
            continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
            game.addEffect(continuousEffect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) LeavesBattlefieldTriggeredAbility(mage.abilities.common.LeavesBattlefieldTriggeredAbility) StanggTwinToken(mage.game.permanent.token.StanggTwinToken) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Effect(mage.abilities.effects.Effect) InfoEffect(mage.abilities.effects.common.InfoEffect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 17 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class SporogenesisRemoveCountersEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (zEvent.isDiesEvent()) {
        Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTargetId());
        if (permanent != null && permanent.isCreature(game) && permanent.getCounters(game).containsKey(CounterType.FUNGUS)) {
            Effect effect = this.getEffects().get(0);
            effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CreateTokenEffect(mage.abilities.effects.common.CreateTokenEffect)

Example 18 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class SuntailSquadronEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Effect effect = new ConjureCardEffect("Suntail Hawk");
    do {
        effect.apply(game, source);
    } while (player.getHand().size() < 7);
    return true;
}
Also used : ConjureCardEffect(mage.abilities.effects.common.ConjureCardEffect) Player(mage.players.Player) Effect(mage.abilities.effects.Effect) OneShotEffect(mage.abilities.effects.OneShotEffect) ConjureCardEffect(mage.abilities.effects.common.ConjureCardEffect)

Example 19 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class TransmogrifyingWandEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature = game.getPermanent(source.getFirstTarget());
    if (creature == null) {
        return false;
    }
    Effect effect = new CreateTokenTargetEffect(new OxToken());
    effect.setTargetPointer(new FixedTarget(creature.getControllerId(), game));
    new DestroyTargetEffect().apply(game, source);
    return effect.apply(game, source);
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) OxToken(mage.game.permanent.token.OxToken) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenTargetEffect(mage.abilities.effects.common.CreateTokenTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) Effect(mage.abilities.effects.Effect)

Example 20 with Effect

use of mage.abilities.effects.Effect in project mage by magefree.

the class ValiantEndeavorEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    List<Integer> results = controller.rollDice(outcome, source, game, 6, 2, 0);
    int firstResult = results.get(0);
    int secondResult = results.get(1);
    int first, second;
    if (firstResult != secondResult && controller.chooseUse(outcome, "Destroy each creature with power greater than or equal to your choice", "The other number will be the amount of 2/2 white Knight tokens with vigilance.", "" + firstResult, "" + secondResult, source, game)) {
        first = firstResult;
        second = secondResult;
    } else {
        first = secondResult;
        second = firstResult;
    }
    final FilterCreaturePermanent filter = new FilterCreaturePermanent(String.format("creatures with power greater than or equal to %s", first));
    filter.add(new PowerPredicate(ComparisonType.MORE_THAN, first - 1));
    Effect wrathEffect = new DestroyAllEffect(filter);
    wrathEffect.apply(game, source);
    new KnightToken().putOntoBattlefield(second, game, source, source.getControllerId());
    return true;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) PowerPredicate(mage.filter.predicate.mageobject.PowerPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect) KnightToken(mage.game.permanent.token.KnightToken) DestroyAllEffect(mage.abilities.effects.common.DestroyAllEffect)

Aggregations

Effect (mage.abilities.effects.Effect)328 OneShotEffect (mage.abilities.effects.OneShotEffect)254 FixedTarget (mage.target.targetpointer.FixedTarget)224 Permanent (mage.game.permanent.Permanent)180 Player (mage.players.Player)167 UUID (java.util.UUID)75 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)60 Card (mage.cards.Card)57 MageObject (mage.MageObject)41 ContinuousEffect (mage.abilities.effects.ContinuousEffect)40 TargetPermanent (mage.target.TargetPermanent)39 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)38 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)38 FilterPermanent (mage.filter.FilterPermanent)29 ReturnToBattlefieldUnderOwnerControlTargetEffect (mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect)28 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)27 AddCountersTargetEffect (mage.abilities.effects.common.counter.AddCountersTargetEffect)25 DamageTargetEffect (mage.abilities.effects.common.DamageTargetEffect)24 AttachEffect (mage.abilities.effects.common.AttachEffect)23 Target (mage.target.Target)22