mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
CanBlockAny: rewrite for 'can block an additional' and 'can block any number'
This commit is contained in:
@@ -547,8 +547,7 @@ public class AiAttackController {
|
||||
remainingAttackers.removeAll(unblockedAttackers);
|
||||
|
||||
for (Card blocker : this.blockers) {
|
||||
if (blocker.hasKeyword("CARDNAME can block any number of creatures.")
|
||||
|| blocker.hasKeyword("CARDNAME can block an additional ninety-nine creatures each combat.")) {
|
||||
if (blocker.canBlockAny()) {
|
||||
for (Card attacker : this.attackers) {
|
||||
if (CombatUtil.canBlock(attacker, blocker)) {
|
||||
remainingAttackers.remove(attacker);
|
||||
@@ -564,6 +563,7 @@ public class AiAttackController {
|
||||
if (remainingAttackers.isEmpty() || maxBlockersAfterCrew == 0) {
|
||||
break;
|
||||
}
|
||||
// TODO replace with better amount
|
||||
if (blocker.hasKeyword("CARDNAME can block an additional creature each combat.")) {
|
||||
blockedAttackers.add(remainingAttackers.get(0));
|
||||
remainingAttackers.remove(0);
|
||||
@@ -884,7 +884,7 @@ public class AiAttackController {
|
||||
final int outNumber = computerForces - humanForces;
|
||||
|
||||
for (Card blocker : this.blockers) {
|
||||
if (blocker.hasKeyword("CARDNAME can block any number of creatures.")) {
|
||||
if (blocker.canBlockAny()) {
|
||||
aiLifeToPlayerDamageRatio--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1581,9 +1581,6 @@ public class AttachAi extends SpellAbilityAi {
|
||||
&& CombatUtil.canBlock(card, true);
|
||||
} else if (keyword.equals("Reach")) {
|
||||
return !card.hasKeyword(Keyword.FLYING) && CombatUtil.canBlock(card, true);
|
||||
} else if (keyword.endsWith("CARDNAME can block an additional creature each combat.")) {
|
||||
return CombatUtil.canBlock(card, true) && !card.hasKeyword("CARDNAME can block any number of creatures.")
|
||||
&& !card.hasKeyword("CARDNAME can block an additional ninety-nine creatures each combat.");
|
||||
} else if (keyword.equals("CARDNAME can attack as though it didn't have defender.")) {
|
||||
return card.hasKeyword(Keyword.DEFENDER) && card.getNetCombatDamage() + powerBonus > 0;
|
||||
} else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) {
|
||||
|
||||
@@ -256,7 +256,7 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (keyword.equals("Bushido")) {
|
||||
} else if (keyword.startsWith("Bushido")) {
|
||||
return !ph.isPlayerTurn(opp) && (CombatUtil.canAttack(card, opp) || (combat != null && combat.isAttacking(card)))
|
||||
&& !ph.getPhase().isAfter(PhaseType.COMBAT_DECLARE_BLOCKERS)
|
||||
&& !opp.getCreaturesInPlay().isEmpty()
|
||||
@@ -335,22 +335,6 @@ public abstract class PumpAiBase extends SpellAbilityAi {
|
||||
&& !CardLists.getKeyword(game.getCombat().getAttackers(), Keyword.FLYING).isEmpty()
|
||||
&& !card.hasKeyword(Keyword.FLYING)
|
||||
&& CombatUtil.canBlock(card);
|
||||
} else if (keyword.endsWith("CARDNAME can block an additional creature each combat.")) {
|
||||
if (ph.isPlayerTurn(ai)
|
||||
|| !ph.getPhase().equals(PhaseType.COMBAT_DECLARE_ATTACKERS)) {
|
||||
return false;
|
||||
}
|
||||
int canBlockNum = 1 + CombatUtil.numberOfAdditionalCreaturesCanBlock(card);
|
||||
int possibleBlockNum = 0;
|
||||
for (Card attacker : game.getCombat().getAttackers()) {
|
||||
if (CombatUtil.canBlock(attacker, card)) {
|
||||
possibleBlockNum++;
|
||||
if (possibleBlockNum > canBlockNum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleBlockNum > canBlockNum;
|
||||
} else if (keyword.equals("Shroud") || keyword.equals("Hexproof")) {
|
||||
return ComputerUtil.predictThreatenedObjects(sa.getActivatingPlayer(), sa).contains(card);
|
||||
} else if (keyword.equals("Persist")) {
|
||||
|
||||
Reference in New Issue
Block a user