Search in sources :

Example 86 with MageObjectReference

use of mage.MageObjectReference in project mage by magefree.

the class RaziaBorosArchangelEffect method init.

@Override
public void init(Ability source, Game game) {
    super.init(source, game);
    redirectToObject = new MageObjectReference(source.getTargets().get(1).getFirstTarget(), game);
}
Also used : MageObjectReference(mage.MageObjectReference)

Example 87 with MageObjectReference

use of mage.MageObjectReference in project mage by magefree.

the class SuspendEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (controller == null || permanent == null) {
        return false;
    }
    Card card = permanent.getMainCard();
    if (!controller.moveCards(permanent, Zone.EXILED, source, game) || game.getState().getZone(card.getId()) != Zone.EXILED) {
        return true;
    }
    UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
    if (!controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
        return true;
    }
    card.addCounters(CounterType.TIME.createInstance(2), source.getControllerId(), source, game);
    if (!card.getAbilities(game).containsClass(SuspendAbility.class)) {
        game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
    }
    game.informPlayers(controller.getLogName() + " suspends 2 - " + card.getName());
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) SuspendAbility(mage.abilities.keyword.SuspendAbility) UUID(java.util.UUID) GainSuspendEffect(mage.abilities.effects.common.continuous.GainSuspendEffect) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 88 with MageObjectReference

use of mage.MageObjectReference in project mage by magefree.

the class TheUpsideDownLeavesAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
    Set<MageObjectReference> morSet = (Set<MageObjectReference>) game.getState().getValue(TheUpsideDown.makeKey(this, game));
    return morSet != null && !morSet.isEmpty() && morSet.stream().anyMatch(mor -> mor.refersTo(zEvent.getTarget(), game));
}
Also used : BlackManaAbility(mage.abilities.mana.BlackManaAbility) StaticFilters(mage.filter.StaticFilters) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) Zone(mage.constants.Zone) PayLifeCost(mage.abilities.costs.common.PayLifeCost) Outcome(mage.constants.Outcome) Set(java.util.Set) MageObjectReference(mage.MageObjectReference) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) HashSet(java.util.HashSet) TriggeredAbilityImpl(mage.abilities.TriggeredAbilityImpl) Game(mage.game.Game) GameEvent(mage.game.events.GameEvent) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) Card(mage.cards.Card) SuperType(mage.constants.SuperType) Ability(mage.abilities.Ability) ZoneChangeEvent(mage.game.events.ZoneChangeEvent) Set(java.util.Set) HashSet(java.util.HashSet) MageObjectReference(mage.MageObjectReference)

Example 89 with MageObjectReference

use of mage.MageObjectReference in project mage by magefree.

the class ViviensInvocationDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
    if (cards.isEmpty()) {
        return true;
    }
    TargetCard target = new TargetCard(Zone.LIBRARY, filter);
    target.setNotTarget(true);
    controller.choose(Outcome.PutCreatureInPlay, cards, target, game);
    Card card = cards.get(target.getFirstTarget(), game);
    if (card == null) {
        controller.putCardsOnBottomOfLibrary(cards, game, source, false);
        return true;
    }
    if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
        cards.remove(card);
    }
    Permanent permanent = game.getPermanent(card.getId());
    if (permanent == null) {
        controller.putCardsOnBottomOfLibrary(cards, game, source, false);
        return true;
    }
    ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ViviensInvocationDamageEffect(new MageObjectReference(permanent, game)), false, "it deals damage equals to its power to target creature an opponent controls");
    ability.addTarget(new TargetOpponentsCreaturePermanent());
    game.fireReflexiveTriggeredAbility(ability, source);
    controller.putCardsOnBottomOfLibrary(cards, game, source, false);
    return true;
}
Also used : Player(mage.players.Player) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetOpponentsCreaturePermanent(mage.target.common.TargetOpponentsCreaturePermanent) ReflexiveTriggeredAbility(mage.abilities.common.delayed.ReflexiveTriggeredAbility) TargetCard(mage.target.TargetCard) MageObjectReference(mage.MageObjectReference) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) TargetCard(mage.target.TargetCard)

Example 90 with MageObjectReference

use of mage.MageObjectReference in project mage by magefree.

the class VisionCharmEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
        Permanent land = it.next().getPermanent(game);
        if (land == null) {
            it.remove();
            continue;
        }
        land.removeAllSubTypes(game, SubTypeSet.NonBasicLandType);
        land.addSubType(game, targetBasicLandType);
        land.removeAllAbilities(source.getSourceId(), game);
        switch(targetBasicLandType) {
            case FOREST:
                land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
                break;
            case PLAINS:
                land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
                break;
            case MOUNTAIN:
                land.addAbility(new RedManaAbility(), source.getSourceId(), game);
                break;
            case ISLAND:
                land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
                break;
            case SWAMP:
                land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
                break;
        }
    }
    return true;
}
Also used : FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) TargetArtifactPermanent(mage.target.common.TargetArtifactPermanent) Permanent(mage.game.permanent.Permanent) MageObjectReference(mage.MageObjectReference)

Aggregations

MageObjectReference (mage.MageObjectReference)250 Permanent (mage.game.permanent.Permanent)147 Player (mage.players.Player)76 UUID (java.util.UUID)47 Card (mage.cards.Card)45 Ability (mage.abilities.Ability)34 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)33 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)26 OneShotEffect (mage.abilities.effects.OneShotEffect)24 FilterPermanent (mage.filter.FilterPermanent)23 Game (mage.game.Game)22 Spell (mage.game.stack.Spell)21 TargetPermanent (mage.target.TargetPermanent)20 CardImpl (mage.cards.CardImpl)18 CardSetInfo (mage.cards.CardSetInfo)18 MageObject (mage.MageObject)17 Effect (mage.abilities.effects.Effect)16 HashSet (java.util.HashSet)15 mage.constants (mage.constants)14 GameEvent (mage.game.events.GameEvent)13