Search in sources :

Example 1 with FixedTarget

use of mage.target.targetpointer.FixedTarget 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 FixedTarget

use of mage.target.targetpointer.FixedTarget 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 FixedTarget

use of mage.target.targetpointer.FixedTarget in project mage by magefree.

the class BorosBattleshaperEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature1 = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    if (creature1 != null) {
        if (game.getOpponents(creature1.getControllerId()).contains(game.getActivePlayerId())) {
            // Blocks
            ContinuousEffectImpl effect = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
            effect = new GainAbilityTargetEffect(BlocksThisTurnMarkerAbility.getInstance(), Duration.EndOfTurn, "");
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
        } else {
            // Attacks
            ContinuousEffectImpl effect = new AttacksIfAbleTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
            effect = new GainAbilityTargetEffect(AttacksThisTurnMarkerAbility.getInstance(), Duration.EndOfTurn, "");
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
        }
    }
    Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (creature2 != null) {
        if (game.getOpponents(creature2.getControllerId()).contains(game.getActivePlayerId())) {
            // Blocks
            ContinuousEffectImpl effect = new CantBlockTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature2.getId(), game));
            game.addEffect(effect, source);
        } else {
            // Attacks
            ContinuousEffectImpl effect = new CantAttackTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature2.getId(), game));
            game.addEffect(effect, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CantAttackTargetEffect(mage.abilities.effects.common.combat.CantAttackTargetEffect) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) CantBlockTargetEffect(mage.abilities.effects.common.combat.CantBlockTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) AttacksIfAbleTargetEffect(mage.abilities.effects.common.combat.AttacksIfAbleTargetEffect)

Example 4 with FixedTarget

use of mage.target.targetpointer.FixedTarget 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 5 with FixedTarget

use of mage.target.targetpointer.FixedTarget 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)

Aggregations

FixedTarget (mage.target.targetpointer.FixedTarget)746 Permanent (mage.game.permanent.Permanent)491 Player (mage.players.Player)385 ContinuousEffect (mage.abilities.effects.ContinuousEffect)248 Effect (mage.abilities.effects.Effect)222 OneShotEffect (mage.abilities.effects.OneShotEffect)185 UUID (java.util.UUID)178 Card (mage.cards.Card)174 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)116 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)109 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)101 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)87 TargetPermanent (mage.target.TargetPermanent)84 FilterPermanent (mage.filter.FilterPermanent)71 MageObject (mage.MageObject)68 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)63 BoostTargetEffect (mage.abilities.effects.common.continuous.BoostTargetEffect)53 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)53 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)50 FilterCard (mage.filter.FilterCard)46