Search in sources :

Example 1 with FlashbackAbility

use of mage.abilities.keyword.FlashbackAbility in project mage by magefree.

the class BosiumStripReplacementEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (!(source instanceof FlashbackAbility) && affectedControllerId.equals(source.getControllerId())) {
        Player player = game.getPlayer(affectedControllerId);
        Card card = game.getCard(objectId);
        if (card != null && player != null && card.equals(player.getGraveyard().getTopCard(game)) && StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY.match(card, game) && game.getState().getZone(objectId) == Zone.GRAVEYARD) {
            game.getState().setValue("BosiumStrip", card);
            return true;
        }
    }
    return false;
}
Also used : FlashbackAbility(mage.abilities.keyword.FlashbackAbility) Player(mage.players.Player) Card(mage.cards.Card)

Example 2 with FlashbackAbility

use of mage.abilities.keyword.FlashbackAbility in project mage by magefree.

the class BackdraftHellkiteEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.getGraveyard().stream().filter(cardId -> affectedObjectList.contains(new MageObjectReference(cardId, game))).forEachOrdered(cardId -> {
        Card card = game.getCard(cardId);
        if (card == null) {
            return;
        }
        FlashbackAbility ability = new FlashbackAbility(card, card.getManaCost());
        ability.setSourceId(cardId);
        ability.setControllerId(card.getOwnerId());
        game.getState().addOtherAbility(card, ability);
    });
    return true;
}
Also used : AttacksTriggeredAbility(mage.abilities.common.AttacksTriggeredAbility) MageObjectReference(mage.MageObjectReference) UUID(java.util.UUID) MageInt(mage.MageInt) Player(mage.players.Player) CardSetInfo(mage.cards.CardSetInfo) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) FlyingAbility(mage.abilities.keyword.FlyingAbility) Card(mage.cards.Card) mage.constants(mage.constants) Ability(mage.abilities.Ability) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) Player(mage.players.Player) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 3 with FlashbackAbility

use of mage.abilities.keyword.FlashbackAbility in project mage by magefree.

the class PastInFlamesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.getGraveyard().stream().filter((cardId) -> (affectedObjectList.contains(new MageObjectReference(cardId, game)))).forEachOrdered((cardId) -> {
        Card card = game.getCard(cardId);
        if (card != null) {
            FlashbackAbility ability = new FlashbackAbility(card, card.getManaCost());
            ability.setSourceId(cardId);
            ability.setControllerId(card.getOwnerId());
            game.getState().addOtherAbility(card, ability);
        }
    });
    return true;
}
Also used : CardSetInfo(mage.cards.CardSetInfo) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) Game(mage.game.Game) CardImpl(mage.cards.CardImpl) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) MageObjectReference(mage.MageObjectReference) UUID(java.util.UUID) Card(mage.cards.Card) mage.constants(mage.constants) Player(mage.players.Player) Ability(mage.abilities.Ability) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) Player(mage.players.Player) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 4 with FlashbackAbility

use of mage.abilities.keyword.FlashbackAbility in project mage by magefree.

the class DralnuLichLordFlashbackEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(targetPointer.getFirst(game, source));
    if (card != null) {
        FlashbackAbility ability = new FlashbackAbility(card, card.getManaCost());
        ability.setSourceId(card.getId());
        ability.setControllerId(card.getOwnerId());
        game.getState().addOtherAbility(card, ability);
        return true;
    }
    return false;
}
Also used : FlashbackAbility(mage.abilities.keyword.FlashbackAbility) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 5 with FlashbackAbility

use of mage.abilities.keyword.FlashbackAbility in project mage by magefree.

the class KessDissidentMageWatcher method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (source instanceof FlashbackAbility || !affectedControllerId.equals(source.getControllerId()) || !game.isActivePlayer(source.getControllerId())) {
        return false;
    }
    Card card = game.getCard(objectId);
    if (card == null || !card.isInstantOrSorcery(game) || !game.getState().getZone(objectId).equals(Zone.GRAVEYARD) || !card.isOwnedBy(source.getControllerId())) {
        return false;
    }
    // check if not already a card was cast this turn with this ability
    KessDissidentMageWatcher watcher = game.getState().getWatcher(KessDissidentMageWatcher.class);
    return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game));
}
Also used : FlashbackAbility(mage.abilities.keyword.FlashbackAbility) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Aggregations

FlashbackAbility (mage.abilities.keyword.FlashbackAbility)9 Card (mage.cards.Card)8 Player (mage.players.Player)5 MageObjectReference (mage.MageObjectReference)3 Ability (mage.abilities.Ability)3 FilterCard (mage.filter.FilterCard)3 UUID (java.util.UUID)2 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)2 ContinuousEffectImpl (mage.abilities.effects.ContinuousEffectImpl)2 CardImpl (mage.cards.CardImpl)2 CardSetInfo (mage.cards.CardSetInfo)2 mage.constants (mage.constants)2 Game (mage.game.Game)2 MageInt (mage.MageInt)1 AttacksTriggeredAbility (mage.abilities.common.AttacksTriggeredAbility)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ChangelingAbility (mage.abilities.keyword.ChangelingAbility)1 FlyingAbility (mage.abilities.keyword.FlyingAbility)1 ReconfigureAbility (mage.abilities.keyword.ReconfigureAbility)1