Search in sources :

Example 1 with ContinuousEffect

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

the class AureliasFuryDamagedByWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    AureliasFuryDamagedByWatcher watcher = game.getState().getWatcher(AureliasFuryDamagedByWatcher.class, source.getSourceId());
    if (watcher != null) {
        for (UUID creatureId : watcher.getDamagedCreatures()) {
            Permanent permanent = game.getPermanent(creatureId);
            if (permanent != null) {
                permanent.tap(source, game);
            }
        }
        for (UUID playerId : watcher.getDamagedPlayers()) {
            ContinuousEffect effect = new AureliasFuryCantCastEffect();
            effect.setTargetPointer(new FixedTarget(playerId));
            game.addEffect(effect, source);
        }
        watcher.reset();
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID)

Example 2 with ContinuousEffect

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

the class ProtectionChosenColorTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (target != null) {
            ChoiceColor colorChoice = new ChoiceColor();
            if (!controller.choose(Outcome.Benefit, colorChoice, game)) {
                return false;
            }
            game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + colorChoice.getChoice());
            game.getState().setValue(target.getId() + "_color", colorChoice.getColor());
            ObjectColor protectColor = (ObjectColor) game.getState().getValue(target.getId() + "_color");
            if (protectColor != null) {
                ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
                game.addEffect(effect, source);
                ObjectColor color = target.getColor(game);
                for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
                    if (!permanent.getId().equals(target.getId()) && permanent.getColor(game).shares(color)) {
                        game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
                        effect.setTargetPointer(new FixedTarget(permanent, game));
                        game.addEffect(effect, source);
                    }
                }
            }
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ObjectColor(mage.ObjectColor) ContinuousEffect(mage.abilities.effects.ContinuousEffect) ChoiceColor(mage.choices.ChoiceColor)

Example 3 with ContinuousEffect

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

the class BondOfPassionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
        permanent.untap(game);
        effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        game.addEffect(effect, source);
    }
    Permanent permanent2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (permanent2 != null) {
        permanent2.damage(2, source.getSourceId(), source, game);
    } else {
        Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget());
        if (player != null) {
            player.damage(2, source.getSourceId(), source, game);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 4 with ContinuousEffect

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

the class BondOfRevivalEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getFirstTarget());
    if (player == null || card == null) {
        return false;
    }
    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.UntilYourNextTurn);
    effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game) + 1));
    if (player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        game.addEffect(effect, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Card(mage.cards.Card)

Example 5 with ContinuousEffect

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

the class CheeringFanaticEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    new ChooseACardNameEffect(TypeOfName.ALL).apply(game, source);
    String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
    if (cardName == null) {
        return false;
    }
    FilterCard filter = new FilterCard();
    filter.add(new NamePredicate(cardName));
    ContinuousEffect effect = new SpellsCostReductionAllEffect(filter, 1);
    effect.setDuration(Duration.EndOfTurn);
    game.addEffect(effect, source);
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) ChooseACardNameEffect(mage.abilities.effects.common.ChooseACardNameEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SpellsCostReductionAllEffect(mage.abilities.effects.common.cost.SpellsCostReductionAllEffect)

Aggregations

ContinuousEffect (mage.abilities.effects.ContinuousEffect)322 FixedTarget (mage.target.targetpointer.FixedTarget)245 Player (mage.players.Player)225 Permanent (mage.game.permanent.Permanent)202 Card (mage.cards.Card)97 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)76 UUID (java.util.UUID)65 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)55 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)50 MageObject (mage.MageObject)47 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)43 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)37 FilterCard (mage.filter.FilterCard)34 TargetPermanent (mage.target.TargetPermanent)33 Effect (mage.abilities.effects.Effect)32 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)31 OneShotEffect (mage.abilities.effects.OneShotEffect)30 Target (mage.target.Target)30 FilterPermanent (mage.filter.FilterPermanent)24 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)23