Search in sources :

Example 71 with MageObject

use of mage.MageObject in project mage by magefree.

the class DarigaazReincarnatedReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
    if (sourceObject instanceof Card) {
        Card card = (Card) sourceObject;
        new RemoveCounterSourceEffect(CounterType.EGG.createInstance()).apply(game, source);
        if (card.getCounters(game).getCount(CounterType.EGG) == 0) {
            controller.moveCards(card, Zone.BATTLEFIELD, source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) RemoveCounterSourceEffect(mage.abilities.effects.common.counter.RemoveCounterSourceEffect) Card(mage.cards.Card)

Example 72 with MageObject

use of mage.MageObject in project mage by magefree.

the class DarkDecisionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && sourceObject != null) {
        TargetCardInLibrary target = new TargetCardInLibrary(new FilterNonlandCard());
        target.setCardLimit(10);
        if (controller.searchLibrary(target, source, game)) {
            UUID targetId = target.getFirstTarget();
            Card card = game.getCard(targetId);
            if (card != null) {
                controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName());
                ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn);
                effect.setTargetPointer(new FixedTarget(card.getId(), game));
                game.addEffect(effect, source);
            }
            controller.shuffleLibrary(source, game);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) FilterNonlandCard(mage.filter.common.FilterNonlandCard) PlayFromNotOwnHandZoneTargetEffect(mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect) MageObject(mage.MageObject) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card)

Example 73 with MageObject

use of mage.MageObject in project mage by magefree.

the class MoveCounterFromTargetToTargetEffect 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) {
        Permanent fromPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
        if (fromPermanent != null && fromPermanent.getCounters(game).getCount(CounterType.P1P1) > 0) {
            Permanent toPermanent = game.getPermanent(source.getTargets().get(1).getFirstTarget());
            if (toPermanent != null) {
                fromPermanent.removeCounters(CounterType.P1P1.createInstance(), source, game);
                toPermanent.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
                game.informPlayers(sourceObject.getLogName() + ": Moved a +1/+1 counter from " + fromPermanent.getLogName() + " to " + toPermanent.getLogName());
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject)

Example 74 with MageObject

use of mage.MageObject in project mage by magefree.

the class DomriChaosBringerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (!event.getSourceId().equals(spellId)) {
        return false;
    }
    if (game.getTurnNum() != turnNumber) {
        return false;
    }
    MageObject mo = game.getObject(event.getTargetId());
    if (mo == null || !mo.isCreature(game)) {
        return false;
    }
    StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
    if (stackObject == null) {
        return false;
    }
    this.getEffects().clear();
    FilterCard filter = new FilterCard();
    filter.add(new CardIdPredicate(stackObject.getSourceId()));
    this.addEffect(new GainAbilityControlledSpellsEffect(new RiotAbility(), filter));
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) RiotAbility(mage.abilities.keyword.RiotAbility) MageObject(mage.MageObject) StackObject(mage.game.stack.StackObject) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) GainAbilityControlledSpellsEffect(mage.abilities.effects.common.continuous.GainAbilityControlledSpellsEffect)

Example 75 with MageObject

use of mage.MageObject in project mage by magefree.

the class DomriRadeEffect1 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (sourceObject != null && controller != null && controller.getLibrary().hasCards()) {
        Card card = controller.getLibrary().getFromTop(game);
        if (card != null) {
            CardsImpl cards = new CardsImpl();
            cards.add(card);
            controller.lookAtCards(sourceObject.getName(), cards, game);
            if (card.isCreature(game)) {
                if (controller.chooseUse(outcome, "Reveal " + card.getName() + " and put it into your hand?", source, game)) {
                    controller.moveCards(card, Zone.HAND, source, game);
                    controller.revealCards(sourceObject.getIdName(), cards, game);
                }
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Aggregations

MageObject (mage.MageObject)738 Player (mage.players.Player)554 Permanent (mage.game.permanent.Permanent)239 UUID (java.util.UUID)224 Card (mage.cards.Card)210 FilterCard (mage.filter.FilterCard)113 CardsImpl (mage.cards.CardsImpl)106 TargetCard (mage.target.TargetCard)91 Cards (mage.cards.Cards)73 Spell (mage.game.stack.Spell)68 FixedTarget (mage.target.targetpointer.FixedTarget)66 HashSet (java.util.HashSet)56 Ability (mage.abilities.Ability)52 ContinuousEffect (mage.abilities.effects.ContinuousEffect)51 TargetPermanent (mage.target.TargetPermanent)48 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)48 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)46 Target (mage.target.Target)44 Effect (mage.abilities.effects.Effect)42 OneShotEffect (mage.abilities.effects.OneShotEffect)41