- Added a chkAIDrawback function to AF LoseLife.

This commit is contained in:
Sloth
2012-12-04 08:37:05 +00:00
parent b061435978
commit 77ec92bed0
2 changed files with 33 additions and 6 deletions

View File

@@ -3,8 +3,8 @@ ManaCost:3 B B
Types:Sorcery
Text:no text
A:SP$ Draw | Cost$ 3 B B | NumCards$ 3 | ValidTgts$ Player | TgtPrompt$ Choose a player | SubAbility$ DBLoseLife | SpellDescription$ Target player draws three cards, loses 3 life, and gets three poison counters.
SVar:DBLoseLife:DB$LoseLife | LifeAmount$ 3 | Defined$ Targeted | SubAbility$ DBPoison
SVar:DBPoison:DB$Poison | Num$ 3 | Defined$ Targeted
SVar:DBLoseLife:DB$ LoseLife | LifeAmount$ 3 | Defined$ Targeted | SubAbility$ DBPoison
SVar:DBPoison:DB$ Poison | Num$ 3 | Defined$ Targeted
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/caress_of_phyrexia.jpg
SetInfo:NPH|Uncommon|http://magiccards.info/scans/en/nph/53.jpg

View File

@@ -18,6 +18,35 @@ import forge.util.MyRandom;
public class LifeLoseAi extends SpellAiLogic {
@Override
public boolean chkAIDrawback(SpellAbility sa, Player ai) {
final Target tgt = sa.getTarget();
ArrayList<Player> tgtPlayers;
if (tgt != null) {
tgtPlayers = tgt.getTargetPlayers();
} else {
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
}
final Card source = sa.getSourceCard();
final String amountStr = sa.getParam("LifeAmount");
int amount = 0;
if (amountStr.equals("X") && source.getSVar(amountStr).equals("Count$xPaid")) {
// Set PayX here to maximum value.
final int xPay = ComputerUtil.determineLeftoverMana(sa, ai);
source.setSVar("PayX", Integer.toString(xPay));
amount = xPay;
} else {
amount = AbilityFactory.calculateAmount(source, amountStr, sa);
}
if (tgtPlayers.contains(ai) && amount > 0 && amount + 3 > ai.getLife()) {
return false;
}
return true;
}
/* (non-Javadoc)
* @see forge.card.abilityfactory.AbilityFactoryAlterLife.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
*/
@@ -141,11 +170,9 @@ public class LifeLoseAi extends SpellAiLogic {
tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), sa.getParam("Defined"), sa);
}
if (!mandatory && tgtPlayers.contains(ai)) {
if (!mandatory && tgtPlayers.contains(ai) && amount > 0 && amount + 3 > ai.getLife()) {
// For cards like Foul Imp, ETB you lose life
if ((amount + 3) > ai.getLife()) {
return false;
}
return false;
}
return true;