Search in sources :

Example 6 with FlashbackAbility

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

the class SnapcasterMageEffect 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 7 with FlashbackAbility

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

the class CardImpl method getAbilities.

/**
 * Gets all current abilities - includes additional abilities added by other
 * cards or effects. Warning, you can't modify that list.
 *
 * @param game
 * @return A list of {@link Ability} - this collection is not modifiable
 */
@Override
public Abilities<Ability> getAbilities(Game game) {
    if (game == null) {
        // deck editor with empty game
        return abilities;
    }
    CardState cardState = game.getState().getCardState(this.getId());
    if (cardState == null) {
        return abilities;
    }
    // collects all abilities
    Abilities<Ability> all = new AbilitiesImpl<>();
    // basic
    if (!cardState.hasLostAllAbilities()) {
        all.addAll(abilities);
    }
    // dynamic
    all.addAll(cardState.getAbilities());
    // workaround to add dynamic flashback ability from main card to all parts (example: Snapcaster Mage gives flashback to split card)
    if (!this.getId().equals(this.getMainCard().getId())) {
        CardState mainCardState = game.getState().getCardState(this.getMainCard().getId());
        if (// lands can't be casted (haven't spell ability), so ignore it
        this.getSpellAbility() != null && mainCardState != null && !mainCardState.hasLostAllAbilities() && mainCardState.getAbilities().containsClass(FlashbackAbility.class)) {
            FlashbackAbility flash = new FlashbackAbility(this, this.getManaCost());
            flash.setSourceId(this.getId());
            flash.setControllerId(this.getOwnerId());
            flash.setSpellAbilityType(this.getSpellAbility().getSpellAbilityType());
            flash.setAbilityName(this.getName());
            all.add(flash);
        }
    }
    return all;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ChangelingAbility(mage.abilities.keyword.ChangelingAbility) ReconfigureAbility(mage.abilities.keyword.ReconfigureAbility) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) FlashbackAbility(mage.abilities.keyword.FlashbackAbility)

Example 8 with FlashbackAbility

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

the class LierDiscipleOfTheDrownedFlashbackEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    for (Card card : player.getGraveyard().getCards(StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY, game)) {
        Ability ability = new FlashbackAbility(card, card.getManaCost());
        ability.setSourceId(card.getId());
        ability.setControllerId(card.getOwnerId());
        game.getState().addOtherAbility(card, ability);
    }
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) Ability(mage.abilities.Ability) FlashbackAbility(mage.abilities.keyword.FlashbackAbility) Player(mage.players.Player) Card(mage.cards.Card)

Example 9 with FlashbackAbility

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

the class RecoupEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    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) Player(mage.players.Player) FilterCard(mage.filter.FilterCard) 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