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;
}
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;
}
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;
}
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;
}
Aggregations