Search in sources :

Example 6 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class CommandoRaidEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    Player opponent = game.getPlayer(event.getPlayerId());
    if (!damageEvent.isCombatDamage() || !event.getSourceId().equals(this.getSourceId()) || opponent == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
    filter.add(new ControllerIdPredicate(opponent.getId()));
    this.getTargets().clear();
    this.addTarget(new TargetCreaturePermanent(filter));
    for (Effect effect : this.getAllEffects()) {
        effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
        effect.setValue("damage", event.getAmount());
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 7 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class FatalLoreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player chosenOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller != null && chosenOpponent != null) {
        if (chosenOpponent.chooseUse(Outcome.Neutral, "If you choose Yes, the controller draws three cards. If no, the controller gets to destroy up to two target creatures that you control and you get to draw up to 3 cards. Those creatures can't be regenerated.", source, game)) {
            controller.drawCards(3, source, game);
        } else {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature");
            filter.add(new ControllerIdPredicate(chosenOpponent.getId()));
            TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false);
            if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) {
                for (UUID targetId : target.getTargets()) {
                    Effect destroyCreature = new DestroyTargetEffect(true);
                    destroyCreature.setTargetPointer(new FixedTarget(targetId, game));
                    destroyCreature.apply(game, source);
                }
                Effect opponentDrawsCards = new DrawCardTargetEffect(StaticValue.get(3), false, true);
                opponentDrawsCards.setTargetPointer(new FixedTarget(chosenOpponent.getId()));
                opponentDrawsCards.apply(game, source);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) UUID(java.util.UUID)

Example 8 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class SoulSeizerEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
    if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
        Player opponent = game.getPlayer(event.getPlayerId());
        if (opponent != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
            filter.add(new ControllerIdPredicate(opponent.getId()));
            this.getTargets().clear();
            this.addTarget(new TargetCreaturePermanent(filter));
            return true;
        }
    }
    return false;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamagedPlayerEvent(mage.game.events.DamagedPlayerEvent)

Example 9 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class LicidSpecialActionEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    Permanent licid = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (licid != null) {
        switch(layer) {
            case TypeChangingEffects_4:
                licid.removeAllCardTypes(game);
                licid.addCardType(game, CardType.ENCHANTMENT);
                licid.removeAllSubTypes(game);
                licid.addSubType(game, SubType.AURA);
                break;
            case AbilityAddingRemovingEffects_6:
                List<Ability> toRemove = new ArrayList<>();
                for (Ability ability : licid.getAbilities(game)) {
                    for (Effect effect : ability.getEffects()) {
                        if (effect instanceof LicidEffect) {
                            toRemove.add(ability);
                            break;
                        }
                    }
                }
                licid.removeAbilities(toRemove, source.getSourceId(), game);
                Ability ability = new EnchantAbility("creature");
                ability.setRuleAtTheTop(true);
                licid.addAbility(ability, source.getSourceId(), game);
                licid.getSpellAbility().getTargets().clear();
                Target target = new TargetCreaturePermanent();
                target.addTarget(this.getTargetPointer().getFirst(game, source), source, game);
                licid.getSpellAbility().getTargets().add(target);
        }
        return true;
    }
    discard();
    return false;
}
Also used : EnchantAbility(mage.abilities.keyword.EnchantAbility) Ability(mage.abilities.Ability) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ArrayList(java.util.ArrayList) OneShotEffect(mage.abilities.effects.OneShotEffect) RemoveSpecialActionEffect(mage.abilities.effects.common.RemoveSpecialActionEffect) Effect(mage.abilities.effects.Effect) CreateSpecialActionEffect(mage.abilities.effects.common.CreateSpecialActionEffect) AttachEffect(mage.abilities.effects.common.AttachEffect) EnchantAbility(mage.abilities.keyword.EnchantAbility)

Example 10 with TargetCreaturePermanent

use of mage.target.common.TargetCreaturePermanent in project mage by magefree.

the class BerserkersFrenzyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE);
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    game.addEffect(new BlocksIfAbleTargetEffect(Duration.EndOfTurn).setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source);
    return true;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) TargetPermanent(mage.target.TargetPermanent) CardsImpl(mage.cards.CardsImpl)

Aggregations

TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)71 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)59 Player (mage.players.Player)49 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)37 Permanent (mage.game.permanent.Permanent)35 UUID (java.util.UUID)25 Target (mage.target.Target)18 FixedTarget (mage.target.targetpointer.FixedTarget)18 Effect (mage.abilities.effects.Effect)8 ContinuousEffect (mage.abilities.effects.ContinuousEffect)7 OneShotEffect (mage.abilities.effects.OneShotEffect)7 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)6 Card (mage.cards.Card)6 DamagedPlayerEvent (mage.game.events.DamagedPlayerEvent)6 ArrayList (java.util.ArrayList)5 Ability (mage.abilities.Ability)5 MageObject (mage.MageObject)4 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)4 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)4 RestrictionEffect (mage.abilities.effects.RestrictionEffect)3