Search in sources :

Example 76 with TargetControlledCreaturePermanent

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

the class CurfewEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    game.informPlayers("Each player returns a creature they control to its owner's hand");
    for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
        Player player = game.getPlayer(playerId);
        if (player != null && game.getBattlefield().countAll(StaticFilters.FILTER_PERMANENT_CREATURE, playerId, game) > 0) {
            TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_CREATURE, true);
            player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game);
            Permanent permanent = game.getPermanent(target.getFirstTarget());
            if (permanent != null) {
                player.moveCards(permanent, Zone.HAND, source, game);
            }
        }
    }
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) UUID(java.util.UUID) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 77 with TargetControlledCreaturePermanent

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

the class DeathsPresenceTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zoneChangeEvent = (ZoneChangeEvent) event;
    if (zoneChangeEvent.isDiesEvent()) {
        Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD);
        if (permanent != null && permanent.isControlledBy(this.getControllerId()) && permanent.isCreature(game)) {
            this.getTargets().clear();
            this.addTarget(new TargetControlledCreaturePermanent());
            this.getEffects().clear();
            this.addEffect(new AddCountersTargetEffect(CounterType.P1P1.createInstance(permanent.getPower().getValue())));
            return true;
        }
    }
    return false;
}
Also used : ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) AddCountersTargetEffect(mage.abilities.effects.common.counter.AddCountersTargetEffect)

Example 78 with TargetControlledCreaturePermanent

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

the class BronzehideLionContinuousEffect method apply.

@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
    if (game.getState().getZoneChangeCounter(source.getSourceId()) > zoneChangeCounter) {
        discard();
    }
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    if (sourceObject == null) {
        sourceObject = game.getPermanentEntering(source.getSourceId());
    }
    if (sourceObject == null) {
        return false;
    }
    Permanent lion = sourceObject;
    switch(layer) {
        case TypeChangingEffects_4:
            lion.removeAllCardTypes(game);
            lion.addCardType(game, CardType.ENCHANTMENT);
            lion.removeAllSubTypes(game);
            lion.addSubType(game, SubType.AURA);
            break;
        case AbilityAddingRemovingEffects_6:
            List<Ability> toRemove = new ArrayList<>();
            for (Ability ability : lion.getAbilities(game)) {
                if (!lion.getSpellAbility().equals(ability)) {
                    toRemove.add(ability);
                }
            }
            lion.removeAbilities(toRemove, source.getSourceId(), game);
            lion.getSpellAbility().getTargets().clear();
            lion.getSpellAbility().getEffects().clear();
            TargetPermanent auraTarget = new TargetControlledCreaturePermanent();
            lion.getSpellAbility().addTarget(auraTarget);
            lion.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
            lion.addAbility(new EnchantAbility(auraTarget.getTargetName()), source.getSourceId(), game);
            // add the activated ability
            activatedAbility.setControllerId(source.getControllerId());
            lion.addAbility(activatedAbility, source.getSourceId(), game);
            break;
    }
    return true;
}
Also used : IndestructibleAbility(mage.abilities.keyword.IndestructibleAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) DiesSourceTriggeredAbility(mage.abilities.common.DiesSourceTriggeredAbility) EnchantAbility(mage.abilities.keyword.EnchantAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ArrayList(java.util.ArrayList) TargetPermanent(mage.target.TargetPermanent) EnchantAbility(mage.abilities.keyword.EnchantAbility) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) AttachEffect(mage.abilities.effects.common.AttachEffect)

Aggregations

TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)78 Player (mage.players.Player)73 Permanent (mage.game.permanent.Permanent)64 Target (mage.target.Target)41 UUID (java.util.UUID)29 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)27 TargetPermanent (mage.target.TargetPermanent)18 ArrayList (java.util.ArrayList)14 Cost (mage.abilities.costs.Cost)10 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)9 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)8 FixedTarget (mage.target.targetpointer.FixedTarget)8 Ability (mage.abilities.Ability)6 FilterPermanent (mage.filter.FilterPermanent)6 MageObject (mage.MageObject)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 OneShotEffect (mage.abilities.effects.OneShotEffect)4 Card (mage.cards.Card)4 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3