Search in sources :

Example 96 with Player

use of mage.players.Player in project mage by magefree.

the class HatefulEidolonTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    int auraCount = 0;
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    if (!zEvent.isDiesEvent()) {
        return false;
    }
    Permanent deadCreature = game.getPermanentOrLKIBattlefield(event.getTargetId());
    if (deadCreature.getAttachments().isEmpty()) {
        return false;
    }
    for (UUID auraId : deadCreature.getAttachments()) {
        Permanent attachment = game.getPermanentOrLKIBattlefield(auraId);
        if (attachment.getControllerId().equals(controllerId) && attachment.isEnchantment(game)) {
            // Shadowspear or any other equipment does not count
            auraCount += 1;
        }
    }
    if (auraCount == 0) {
        // just equipment not aura's
        return false;
    }
    Player controller = game.getPlayer(controllerId);
    if (controller != null && controller.canRespond()) {
        this.getEffects().clear();
        DrawCardTargetEffect drawCard = new DrawCardTargetEffect(auraCount);
        drawCard.setTargetPointer(new FixedTarget(controllerId));
        this.addEffect(drawCard);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) DrawCardTargetEffect(mage.abilities.effects.common.DrawCardTargetEffect) UUID(java.util.UUID)

Example 97 with Player

use of mage.players.Player in project mage by magefree.

the class HaukensInsightWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
            MageObject sourceObject = source.getSourceObject(game);
            String exileName = sourceObject == null ? null : sourceObject.getIdName();
            controller.moveCardsToExile(card, source, game, true, exileId, exileName);
            if (game.getState().getZone(card.getId()) == Zone.EXILED) {
                card.setFaceDown(true, game);
                HaukensInsightLookEffect effect = new HaukensInsightLookEffect(controller.getId());
                effect.setTargetPointer(new FixedTarget(card, game));
                game.addEffect(effect, source);
                return true;
            }
        }
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) MageObject(mage.MageObject) UUID(java.util.UUID) Card(mage.cards.Card)

Example 98 with Player

use of mage.players.Player in project mage by magefree.

the class HaukensInsightWatcher method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (affectedControllerId.equals(source.getControllerId()) && game.isActivePlayer(source.getControllerId())) {
        Player controller = game.getPlayer(source.getControllerId());
        HaukensInsightWatcher watcher = game.getState().getWatcher(HaukensInsightWatcher.class);
        Permanent sourceObject = game.getPermanent(source.getSourceId());
        if (controller != null && watcher != null && sourceObject != null && !watcher.isAbilityUsed(new MageObjectReference(sourceObject, game))) {
            UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), game.getState().getZoneChangeCounter(source.getSourceId()));
            ExileZone exileZone = game.getExile().getExileZone(exileId);
            if (exileZone != null && exileZone.contains(CardUtil.getMainCardId(game, objectId))) {
                allowCardToPlayWithoutMana(objectId, source, affectedControllerId, game);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference)

Example 99 with Player

use of mage.players.Player in project mage by magefree.

the class HarvestSeasonEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        int tappedCreatures = new PermanentsOnBattlefieldCount(filter).calculate(game, source, this);
        if (tappedCreatures > 0) {
            TargetCardInLibrary target = new TargetCardInLibrary(0, tappedCreatures, StaticFilters.FILTER_CARD_BASIC_LAND);
            if (controller.searchLibrary(target, source, game)) {
                controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
            }
        }
        controller.shuffleLibrary(source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) CardsImpl(mage.cards.CardsImpl)

Example 100 with Player

use of mage.players.Player in project mage by magefree.

the class HeartPiercerManticoreSacrificeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
    if (!controller.choose(outcome, target, source.getSourceId(), game)) {
        return false;
    }
    Permanent toSacrifice = game.getPermanent(target.getFirstTarget());
    if (toSacrifice == null) {
        return false;
    }
    int power = toSacrifice.getPower().getValue();
    if (!toSacrifice.sacrifice(source, game)) {
        return false;
    }
    ReflexiveTriggeredAbility trigger = new ReflexiveTriggeredAbility(new DamageTargetEffect(power), false, "{this} deals damage equal to that creature's power to any target.");
    trigger.addTarget(new TargetAnyTarget());
    game.fireReflexiveTriggeredAbility(trigger, source);
    return true;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) TargetAnyTarget(mage.target.common.TargetAnyTarget) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) DamageTargetEffect(mage.abilities.effects.common.DamageTargetEffect) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetAnyTarget(mage.target.common.TargetAnyTarget)

Aggregations

Player (mage.players.Player)3909 Permanent (mage.game.permanent.Permanent)1705 Card (mage.cards.Card)1099 UUID (java.util.UUID)962 MageObject (mage.MageObject)556 FilterCard (mage.filter.FilterCard)515 CardsImpl (mage.cards.CardsImpl)498 FixedTarget (mage.target.targetpointer.FixedTarget)387 TargetPermanent (mage.target.TargetPermanent)353 Cards (mage.cards.Cards)345 TargetCard (mage.target.TargetCard)328 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)317 TargetPlayer (mage.target.TargetPlayer)312 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)301 FilterPermanent (mage.filter.FilterPermanent)292 Target (mage.target.Target)289 OneShotEffect (mage.abilities.effects.OneShotEffect)230 ContinuousEffect (mage.abilities.effects.ContinuousEffect)227 TargetCardInLibrary (mage.target.common.TargetCardInLibrary)207 Effect (mage.abilities.effects.Effect)170