Search in sources :

Example 86 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class ImpromptuRaidEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            Cards cards = new CardsImpl();
            cards.add(card);
            controller.revealCards(sourceObject.getName(), cards, game);
            if (filterPutInGraveyard.match(card, source.getSourceId(), source.getControllerId(), game)) {
                controller.moveCards(card, Zone.GRAVEYARD, source, game);
                return true;
            }
            if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
                Permanent permanent = game.getPermanent(card.getId());
                if (permanent != null) {
                    ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                    effect.setTargetPointer(new FixedTarget(permanent, game));
                    game.addEffect(effect, source);
                    SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("", source.getControllerId());
                    sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
                    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
                    game.addDelayedTriggeredAbility(delayedAbility, source);
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) MageObject(mage.MageObject) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 87 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class ImpelledGiantBoostEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent impelledGiant = game.getPermanent(source.getSourceId());
    Permanent tappedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (tappedCreature != null && impelledGiant != null) {
        int amount = tappedCreature.getPower().getValue();
        game.addEffect(new BoostSourceEffect(amount, 0, Duration.EndOfTurn), source);
    }
    return true;
}
Also used : BoostSourceEffect(mage.abilities.effects.common.continuous.BoostSourceEffect) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent)

Example 88 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class ImmovableRodAttackBlockTargetEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (sourcePermanent == null || !sourcePermanent.isTapped() || permanent == null) {
        discard();
        return false;
    }
    permanent.removeAllAbilities(source.getSourceId(), game);
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent)

Example 89 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class ImprisonUnblockEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent enchantment = game.getPermanent(source.getSourceId());
    if (enchantment != null && enchantment.getAttachedTo() != null) {
        Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
        if (permanent != null) {
            if (permanent.isCreature(game)) {
                // Tap the creature
                permanent.tap(source, game);
                // Remove it from combat
                Effect effect = new RemoveFromCombatTargetEffect();
                effect.setTargetPointer(new FixedTarget(permanent, game));
                effect.apply(game, source);
                // Make blocked creatures unblocked
                BlockedByOnlyOneCreatureThisCombatWatcher watcher = game.getState().getWatcher(BlockedByOnlyOneCreatureThisCombatWatcher.class);
                if (watcher != null) {
                    Set<CombatGroup> combatGroups = watcher.getBlockedOnlyByCreature(permanent.getId());
                    if (combatGroups != null) {
                        for (CombatGroup combatGroup : combatGroups) {
                            if (combatGroup != null) {
                                combatGroup.setBlocked(false, game);
                            }
                        }
                    }
                }
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) RemoveFromCombatTargetEffect(mage.abilities.effects.common.RemoveFromCombatTargetEffect) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) CounterTargetEffect(mage.abilities.effects.common.CounterTargetEffect) DestroySourceEffect(mage.abilities.effects.common.DestroySourceEffect) AttachEffect(mage.abilities.effects.common.AttachEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) RemoveFromCombatTargetEffect(mage.abilities.effects.common.RemoveFromCombatTargetEffect) BlockedByOnlyOneCreatureThisCombatWatcher(mage.watchers.common.BlockedByOnlyOneCreatureThisCombatWatcher) CombatGroup(mage.game.combat.CombatGroup)

Example 90 with Permanent

use of mage.game.permanent.Permanent in project mage by magefree.

the class JusticeEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    MageObject sourceObject = game.getObject(event.getSourceId());
    if (sourceObject != null && sourceObject.getColor(game).isRed()) {
        if (sourceObject instanceof Permanent && sourceObject.isCreature(game) || sourceObject instanceof Spell) {
            this.getEffects().get(0).setValue("damageAmount", event.getAmount());
            this.getEffects().get(0).setTargetPointer(new FixedTarget(game.getControllerId(sourceObject.getId())));
            return true;
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) Spell(mage.game.stack.Spell)

Aggregations

Permanent (mage.game.permanent.Permanent)3269 Player (mage.players.Player)1706 UUID (java.util.UUID)665 TargetPermanent (mage.target.TargetPermanent)571 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)541 FixedTarget (mage.target.targetpointer.FixedTarget)496 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)467 FilterPermanent (mage.filter.FilterPermanent)466 Card (mage.cards.Card)425 MageObject (mage.MageObject)246 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)226 Target (mage.target.Target)225 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)217 ContinuousEffect (mage.abilities.effects.ContinuousEffect)207 Effect (mage.abilities.effects.Effect)183 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)179 Test (org.junit.Test)179 OneShotEffect (mage.abilities.effects.OneShotEffect)175 FilterCard (mage.filter.FilterCard)158 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)153