foul-magics/Mage/src/main/java/mage/abilities/keyword/AdventureCreatureAbility.java
2019-12-09 11:30:11 -05:00

124 lines
4 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.SplitCard;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.players.Player;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
* 702.32. Flashback
*
* 702.32a. Flashback appears on some instants and sorceries. It represents two
* static abilities: one that functions while the card is in a players
* graveyard and the other that functions while the card is on the stack.
* Flashback [cost] means, "You may cast this card from your graveyard by paying
* [cost] rather than paying its mana cost" and, "If the flashback cost was
* paid, exile this card instead of putting it anywhere else any time it would
* leave the stack." Casting a spell using its flashback ability follows the
* rules for paying alternative costs in rules 601.2b and 601.2eg.
*
* @author phulin
*/
public class AdventureCreatureAbility extends SpellAbility {
private String abilityName;
private SpellAbility spellAbilityToResolve;
public AdventureCreatureAbility(Cost cost) {
super(null, "", Zone.EXILED, SpellAbilityType.BASE, SpellAbilityCastMode.NORMAL);
this.setAdditionalCostsRuleVisible(false);
this.name = "Cast creature " + cost.getText();
this.addCost(cost);
this.timing = TimingRule.SORCERY;
}
public AdventureCreatureAbility(final AdventureCreatureAbility ability) {
super(ability);
this.spellAbilityType = ability.spellAbilityType;
this.abilityName = ability.abilityName;
this.spellAbilityToResolve = ability.spellAbilityToResolve;
}
@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
if (super.canActivate(playerId, game).canActivate()) {
Card card = game.getCard(getSourceId());
if (card != null) {
// Card must be in the exile zone, and it must have been cast as an adventure.
if (game.getState().getZone(card.getId()) != Zone.EXILED) {
return ActivationStatus.getFalse();
}
// FIXME: Make sure it was cast as an adventure.
return card.getSpellAbility().canActivate(playerId, game);
}
}
return ActivationStatus.getFalse();
}
@Override
public Costs<Cost> getCosts() {
if (spellAbilityToResolve == null) {
return super.getCosts();
}
return spellAbilityToResolve.getCosts();
}
@Override
public AdventureCreatureAbility copy() {
return new AdventureCreatureAbility(this);
}
@Override
public String getRule(boolean all) {
return this.getRule();
}
@Override
public String getRule() {
StringBuilder sbRule = new StringBuilder("Cast from Adventure");
/*if (!costs.isEmpty()) {
sbRule.append("&mdash;");
} else {
sbRule.append(' ');
}
if (!manaCosts.isEmpty()) {
sbRule.append(manaCosts.getText());
}
if (!costs.isEmpty()) {
if (!manaCosts.isEmpty()) {
sbRule.append(", ");
}
sbRule.append(costs.getText());
sbRule.append('.');
}
if (abilityName != null) {
sbRule.append(' ');
sbRule.append(abilityName);
}
sbRule.append(" <i>(You may cast this card from your graveyard for its flashback cost. Then exile it.)</i>");*/
return sbRule.toString();
}
/**
* Used for split card in PlayerImpl method:
* getOtherUseableActivatedAbilities
*
* @param abilityName
*/
public void setAbilityName(String abilityName) {
this.abilityName = abilityName;
}
}