mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Included mustBlockCard into the existing structures. Renamed canBlockAttackerWithLure to mustBlockAnAttacker.
This commit is contained in:
@@ -253,7 +253,7 @@ public class CombatUtil {
|
||||
//if a creature does not block but should, return false
|
||||
for (Card blocker : blockers) {
|
||||
//lure effects
|
||||
if (!combat.getAllBlockers().contains(blocker) && canBlockAnAttackerWithLure(blocker, combat))
|
||||
if (!combat.getAllBlockers().contains(blocker) && mustBlockAnAttacker(blocker, combat))
|
||||
return false;
|
||||
|
||||
//"CARDNAME blocks each turn if able."
|
||||
@@ -269,13 +269,13 @@ public class CombatUtil {
|
||||
|
||||
// can the blocker block an attacker with a lure effect?
|
||||
/**
|
||||
* <p>canBlockAnAttackerWithLure.</p>
|
||||
* <p>mustBlockAnAttacker.</p>
|
||||
*
|
||||
* @param blocker a {@link forge.Card} object.
|
||||
* @param combat a {@link forge.Combat} object.
|
||||
* @return a boolean.
|
||||
*/
|
||||
public static boolean canBlockAnAttackerWithLure(Card blocker, Combat combat) {
|
||||
public static boolean mustBlockAnAttacker(Card blocker, Combat combat) {
|
||||
|
||||
if (blocker == null) return false;
|
||||
|
||||
@@ -287,6 +287,10 @@ public class CombatUtil {
|
||||
for (Card attacker : attackersWithLure) {
|
||||
if (canBlock(blocker, combat) && canBlock(attacker, blocker)) return true;
|
||||
}
|
||||
|
||||
for (Card attacker : blocker.getMustBlockCards()) {
|
||||
if (canBlock(blocker, combat) && canBlock(attacker, blocker)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -308,8 +312,9 @@ public class CombatUtil {
|
||||
if (canBeBlocked(attacker, combat) == false) return false;
|
||||
|
||||
//if the attacker has no lure effect, but the blocker can block another attacker with lure, the blocker can't block the former
|
||||
if (!attacker.hasKeyword("All creatures able to block CARDNAME do so.")
|
||||
&& canBlockAnAttackerWithLure(blocker, combat)) return false;
|
||||
if ((!attacker.hasKeyword("All creatures able to block CARDNAME do so.")
|
||||
&& mustBlockAnAttacker(blocker, combat))
|
||||
|| !(blocker.getMustBlockCards().contains(attacker))) return false;
|
||||
|
||||
return canBlock(attacker, blocker);
|
||||
}
|
||||
|
||||
@@ -560,8 +560,6 @@ public class ComputerUtil_Block2 {
|
||||
setBlockedButUnkilled(new CardList()); //keeps track of all blocked attackers that currently wouldn't be destroyed
|
||||
CardList blockers;
|
||||
CardList chumpBlockers;
|
||||
|
||||
setupForcedBlocks(combat);
|
||||
|
||||
setDiff(AllZone.getComputerPlayer().getLife() * 2 - 5); //This is the minimal gain for an unnecessary trade
|
||||
|
||||
@@ -627,7 +625,7 @@ public class ComputerUtil_Block2 {
|
||||
chumpBlockers = getBlockersLeft().getKeyword("CARDNAME blocks each turn if able.");
|
||||
// if an attacker with lure attacks - all that can block
|
||||
for (Card blocker : getBlockersLeft()) {
|
||||
if (CombatUtil.canBlockAnAttackerWithLure(blocker, combat)) chumpBlockers.add(blocker);
|
||||
if (CombatUtil.mustBlockAnAttacker(blocker, combat)) chumpBlockers.add(blocker);
|
||||
}
|
||||
if (!chumpBlockers.isEmpty()) {
|
||||
getAttackers().shuffle();
|
||||
@@ -644,20 +642,4 @@ public class ComputerUtil_Block2 {
|
||||
|
||||
return combat;
|
||||
}
|
||||
|
||||
private static void setupForcedBlocks(Combat combat) {
|
||||
CardList blockers = AllZoneUtil.getCreaturesInPlay(combat.getDefendingPlayer());
|
||||
for (Card blocker : blockers) {
|
||||
if (!blocker.getMustBlockCards().isEmpty()) {
|
||||
ArrayList<Card> blocks = blocker.getMustBlockCards();
|
||||
for (Card attacker : blocks) {
|
||||
if (attacker.isAttacking() && CombatUtil.canBlock(attacker, blocker, combat)
|
||||
&& getBlockersLeft().contains(blocker)) {
|
||||
combat.addBlocker(attacker, blocker);
|
||||
getBlockersLeft().remove(blocker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user