mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
*Added beginnings of ExileAndPay Cost (It currently assumes exactly *1* *creature* to exile from the *graveyard*. Good enough for the only card to use it. :P Will expand.)
*Added Back from the Brink.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -701,6 +701,7 @@ res/cardsfolder/a/azors_elocutors.txt -text
|
|||||||
res/cardsfolder/a/azure_drake.txt svneol=native#text/plain
|
res/cardsfolder/a/azure_drake.txt svneol=native#text/plain
|
||||||
res/cardsfolder/a/azure_mage.txt svneol=native#text/plain
|
res/cardsfolder/a/azure_mage.txt svneol=native#text/plain
|
||||||
res/cardsfolder/a/azusa_lost_but_seeking.txt svneol=native#text/plain
|
res/cardsfolder/a/azusa_lost_but_seeking.txt svneol=native#text/plain
|
||||||
|
res/cardsfolder/b/back_from_the_brink.txt -text
|
||||||
res/cardsfolder/b/back_to_basics.txt svneol=native#text/plain
|
res/cardsfolder/b/back_to_basics.txt svneol=native#text/plain
|
||||||
res/cardsfolder/b/back_to_nature.txt svneol=native#text/plain
|
res/cardsfolder/b/back_to_nature.txt svneol=native#text/plain
|
||||||
res/cardsfolder/b/backfire.txt svneol=native#text/plain
|
res/cardsfolder/b/backfire.txt svneol=native#text/plain
|
||||||
@@ -13944,6 +13945,7 @@ src/main/java/forge/card/cost/Cost.java svneol=native#text/plain
|
|||||||
src/main/java/forge/card/cost/CostDamage.java -text
|
src/main/java/forge/card/cost/CostDamage.java -text
|
||||||
src/main/java/forge/card/cost/CostDiscard.java -text
|
src/main/java/forge/card/cost/CostDiscard.java -text
|
||||||
src/main/java/forge/card/cost/CostExile.java -text
|
src/main/java/forge/card/cost/CostExile.java -text
|
||||||
|
src/main/java/forge/card/cost/CostExileAndPay.java -text
|
||||||
src/main/java/forge/card/cost/CostGainLife.java -text
|
src/main/java/forge/card/cost/CostGainLife.java -text
|
||||||
src/main/java/forge/card/cost/CostMill.java -text
|
src/main/java/forge/card/cost/CostMill.java -text
|
||||||
src/main/java/forge/card/cost/CostPart.java -text
|
src/main/java/forge/card/cost/CostPart.java -text
|
||||||
|
|||||||
7
res/cardsfolder/b/back_from_the_brink.txt
Normal file
7
res/cardsfolder/b/back_from_the_brink.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Name:Back from the Brink
|
||||||
|
ManaCost:4 U U
|
||||||
|
Types:Enchantment
|
||||||
|
Text:no text
|
||||||
|
A:AB$ CopyPermanent | Cost$ ExileAndPay | Defined$ Exiled | SorcerySpeed$ True | SpellDescription$ Put a token onto the battlefield that's a copy of that card. Activate this ability only any time you could cast a sorcery.
|
||||||
|
SetInfo:ISD Rare
|
||||||
|
Oracle:Exile a creature card from your graveyard and pay its mana cost: Put a token onto the battlefield that's a copy of that card. Activate this ability only any time you could cast a sorcery.
|
||||||
@@ -301,6 +301,10 @@ public class Cost {
|
|||||||
return new CostExile(splitStr[0], splitStr[1], description, ZoneType.Graveyard, true);
|
return new CostExile(splitStr[0], splitStr[1], description, ZoneType.Graveyard, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(parse.equals("ExileAndPay")) {
|
||||||
|
return new CostExileAndPay();
|
||||||
|
}
|
||||||
|
|
||||||
if(parse.startsWith("Return<")) {
|
if(parse.startsWith("Return<")) {
|
||||||
final String[] splitStr = abCostParse(parse, 3);
|
final String[] splitStr = abCostParse(parse, 3);
|
||||||
final String description = splitStr.length > 2 ? splitStr[2] : null;
|
final String description = splitStr.length > 2 ? splitStr[2] : null;
|
||||||
|
|||||||
160
src/main/java/forge/card/cost/CostExileAndPay.java
Normal file
160
src/main/java/forge/card/cost/CostExileAndPay.java
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
package forge.card.cost;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardLists;
|
||||||
|
import forge.card.spellability.SpellAbility;
|
||||||
|
import forge.card.spellability.SpellAbilityStackInstance;
|
||||||
|
import forge.card.spellability.SpellPermanent;
|
||||||
|
import forge.game.GameState;
|
||||||
|
import forge.game.ai.ComputerUtilCard;
|
||||||
|
import forge.game.ai.ComputerUtilCost;
|
||||||
|
import forge.game.player.AIPlayer;
|
||||||
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.gui.GuiChoose;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CostExileAndPay extends CostPartWithList {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPartWithList#doPayment(forge.card.spellability.SpellAbility, forge.Card)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void doPayment(SpellAbility ability, Card targetCard) {
|
||||||
|
ability.getActivatingPlayer().getGame().getAction().exile(targetCard);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPartWithList#getHashForList()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getHashForList() {
|
||||||
|
return "Exiled";
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPart#canPay(forge.card.spellability.SpellAbility)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean canPay(SpellAbility ability) {
|
||||||
|
return CardLists.getValidCards(ability.getActivatingPlayer().getZone(ZoneType.Graveyard), "Creature", ability.getActivatingPlayer(), ability.getSourceCard()).size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPart#decideAIPayment(forge.game.player.AIPlayer, forge.card.spellability.SpellAbility, forge.Card)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PaymentDecision decideAIPayment(AIPlayer ai, SpellAbility ability, Card source) {
|
||||||
|
List<Card> validGrave = CardLists.getValidCards(ability.getActivatingPlayer().getZone(ZoneType.Graveyard), "Creature", ability.getActivatingPlayer(), ability.getSourceCard());
|
||||||
|
|
||||||
|
if(validGrave.size() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Card bestCard = null;
|
||||||
|
int bestScore = 0;
|
||||||
|
|
||||||
|
for(Card candidate : validGrave)
|
||||||
|
{
|
||||||
|
boolean selectable = false;
|
||||||
|
for(SpellAbility sa : candidate.getSpellAbilities())
|
||||||
|
{
|
||||||
|
if(sa instanceof SpellPermanent)
|
||||||
|
{
|
||||||
|
if(ComputerUtilCost.canPayCost(sa, ai))
|
||||||
|
{
|
||||||
|
selectable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!selectable)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int candidateScore = ComputerUtilCard.evaluateCreature(candidate);
|
||||||
|
if(candidateScore > bestScore)
|
||||||
|
{
|
||||||
|
bestScore = candidateScore;
|
||||||
|
bestCard = candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestCard == null ? null : new PaymentDecision(bestCard);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPart#payHuman(forge.card.spellability.SpellAbility, forge.game.GameState)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean payHuman(SpellAbility ability, GameState game) {
|
||||||
|
List<Card> validGrave = CardLists.getValidCards(ability.getActivatingPlayer().getZone(ZoneType.Graveyard), "Creature", ability.getActivatingPlayer(), ability.getSourceCard());
|
||||||
|
|
||||||
|
Card selectedCard = GuiChoose.oneOrNone("Choose a creature card to exile.", validGrave);
|
||||||
|
if(selectedCard == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Cost> options = new ArrayList<Cost>();
|
||||||
|
for(SpellAbility sa : selectedCard.getSpellAbilities())
|
||||||
|
{
|
||||||
|
if(sa instanceof SpellPermanent)
|
||||||
|
{
|
||||||
|
options.add(sa.getPayCosts());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Cost selectedCost = GuiChoose.oneOrNone("Choose a cost", options);
|
||||||
|
if(selectedCost == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CostPayment pay = new CostPayment(selectedCost, ability);
|
||||||
|
pay.payCost(game);
|
||||||
|
if(!pay.isFullyPaid())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
executePayment(ability,selectedCard);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPart#payAI(forge.card.cost.PaymentDecision, forge.game.player.AIPlayer, forge.card.spellability.SpellAbility, forge.Card)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void payAI(PaymentDecision decision, AIPlayer ai, SpellAbility ability, Card source) {
|
||||||
|
for (final Card c : decision.cards) {
|
||||||
|
executePayment(ability, c);
|
||||||
|
for(SpellAbility sa : c.getSpellAbilities())
|
||||||
|
{
|
||||||
|
if(sa instanceof SpellPermanent && ComputerUtilCost.canPayCost(sa, ai))
|
||||||
|
{
|
||||||
|
final CostPayment pay = new CostPayment(sa.getPayCosts(), sa);
|
||||||
|
pay.payComputerCosts(ai, ai.getGame());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.reportPaidCardsTo(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see forge.card.cost.CostPart#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Exile a creature card from your graveyard and pay it's mana cost";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user