- Added AI support for pump abilities with "CARDNAME can block an additional creature.".

This commit is contained in:
Sloth
2012-09-18 17:51:39 +00:00
parent 6c2143d2cc
commit 6276200cf5
4 changed files with 20 additions and 5 deletions

View File

@@ -5,7 +5,6 @@ Text:no text
PT:1/4
K:Reach
A:AB$ Pump | Cost$ 1 G | Defined$ Self | KW$ HIDDEN CARDNAME can block an additional creature. | SpellDescription$ CARDNAME can block an additional creature this turn.
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/anurid_swarmsnapper.jpg
SetInfo:JUD|Uncommon|http://magiccards.info/scans/en/ju/105.jpg

View File

@@ -5,7 +5,6 @@ Text:no text
PT:1/4
A:AB$ Pump | Cost$ W | Defined$ Self | NumDef$ 1 | SpellDescription$ CARDNAME gets +0/+1 until end of turn.
A:AB$ Pump | Cost$ 2 | Defined$ Self | KW$ HIDDEN CARDNAME can block an additional creature. | SpellDescription$ CARDNAME can block an additional creature this turn.
SVar:RemAIDeck:True
SVar:Rarity:Uncommon
SVar:Picture:http://www.wizards.com/global/images/magic/general/luminous_guardian.jpg
SetInfo:ODY|Uncommon|http://magiccards.info/scans/en/od/31.jpg

View File

@@ -5,7 +5,6 @@ Text:no text
PT:2/3
K:Reach
A:AB$ Pump | Cost$ W | Defined$ Self | KW$ HIDDEN CARDNAME can block an additional creature. | SpellDescription$ CARDNAME can block an additional creature this turn.
SVar:RemAIDeck:True
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/mounted_archers.jpg
SetInfo:TMP|Common|http://magiccards.info/scans/en/tp/242.jpg

View File

@@ -529,6 +529,24 @@ public class AbilityFactoryPump {
|| !CombatUtil.canBlock(card)) {
return false;
}
} else if (keyword.endsWith("CARDNAME can block an additional creature.")) {
if (ph.isPlayerTurn(computer)
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY)) {
return false;
}
int canBlockNum = 1 + card.getKeywordAmount("CARDNAME can block an additional creature.");
int possibleBlockNum = 0;
for (Card attacker : AllZone.getCombat().getAttackerList()) {
if (CombatUtil.canBlock(attacker, card)) {
possibleBlockNum++;
if (possibleBlockNum > canBlockNum) {
break;
}
}
}
if (possibleBlockNum <= canBlockNum) {
return false;
}
} else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) {
if (!AbilityFactory.predictThreatenedObjects(sa.getAbilityFactory()).contains(card)) {
return false;
@@ -597,13 +615,13 @@ public class AbilityFactoryPump {
// is the creature blocking and unable to destroy the attacker
// or would be destroyed itself?
if (c.isBlocking()) {
if (CombatUtil.blockerWouldBeDestroyed(c)) {
if (defense > 0 && CombatUtil.blockerWouldBeDestroyed(c)) {
return true;
}
CardList blockedBy = AllZone.getCombat().getAttackersBlockedBy(c);
// For now, Only care the first creature blocked by a card.
// TODO Add in better BlockAdditional support
if (blockedBy.size() != 0 && !CombatUtil.attackerWouldBeDestroyed(blockedBy.get(0))) {
if (!blockedBy.isEmpty() && attack > 0 && !CombatUtil.attackerWouldBeDestroyed(blockedBy.get(0))) {
return true;
}
}