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
|
//if a creature does not block but should, return false
|
||||||
for (Card blocker : blockers) {
|
for (Card blocker : blockers) {
|
||||||
//lure effects
|
//lure effects
|
||||||
if (!combat.getAllBlockers().contains(blocker) && canBlockAnAttackerWithLure(blocker, combat))
|
if (!combat.getAllBlockers().contains(blocker) && mustBlockAnAttacker(blocker, combat))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//"CARDNAME blocks each turn if able."
|
//"CARDNAME blocks each turn if able."
|
||||||
@@ -269,13 +269,13 @@ public class CombatUtil {
|
|||||||
|
|
||||||
// can the blocker block an attacker with a lure effect?
|
// can the blocker block an attacker with a lure effect?
|
||||||
/**
|
/**
|
||||||
* <p>canBlockAnAttackerWithLure.</p>
|
* <p>mustBlockAnAttacker.</p>
|
||||||
*
|
*
|
||||||
* @param blocker a {@link forge.Card} object.
|
* @param blocker a {@link forge.Card} object.
|
||||||
* @param combat a {@link forge.Combat} object.
|
* @param combat a {@link forge.Combat} object.
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public static boolean canBlockAnAttackerWithLure(Card blocker, Combat combat) {
|
public static boolean mustBlockAnAttacker(Card blocker, Combat combat) {
|
||||||
|
|
||||||
if (blocker == null) return false;
|
if (blocker == null) return false;
|
||||||
|
|
||||||
@@ -287,6 +287,10 @@ public class CombatUtil {
|
|||||||
for (Card attacker : attackersWithLure) {
|
for (Card attacker : attackersWithLure) {
|
||||||
if (canBlock(blocker, combat) && canBlock(attacker, blocker)) return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -308,8 +312,9 @@ public class CombatUtil {
|
|||||||
if (canBeBlocked(attacker, combat) == false) return false;
|
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 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.")
|
if ((!attacker.hasKeyword("All creatures able to block CARDNAME do so.")
|
||||||
&& canBlockAnAttackerWithLure(blocker, combat)) return false;
|
&& mustBlockAnAttacker(blocker, combat))
|
||||||
|
|| !(blocker.getMustBlockCards().contains(attacker))) return false;
|
||||||
|
|
||||||
return canBlock(attacker, blocker);
|
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
|
setBlockedButUnkilled(new CardList()); //keeps track of all blocked attackers that currently wouldn't be destroyed
|
||||||
CardList blockers;
|
CardList blockers;
|
||||||
CardList chumpBlockers;
|
CardList chumpBlockers;
|
||||||
|
|
||||||
setupForcedBlocks(combat);
|
|
||||||
|
|
||||||
setDiff(AllZone.getComputerPlayer().getLife() * 2 - 5); //This is the minimal gain for an unnecessary trade
|
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.");
|
chumpBlockers = getBlockersLeft().getKeyword("CARDNAME blocks each turn if able.");
|
||||||
// if an attacker with lure attacks - all that can block
|
// if an attacker with lure attacks - all that can block
|
||||||
for (Card blocker : getBlockersLeft()) {
|
for (Card blocker : getBlockersLeft()) {
|
||||||
if (CombatUtil.canBlockAnAttackerWithLure(blocker, combat)) chumpBlockers.add(blocker);
|
if (CombatUtil.mustBlockAnAttacker(blocker, combat)) chumpBlockers.add(blocker);
|
||||||
}
|
}
|
||||||
if (!chumpBlockers.isEmpty()) {
|
if (!chumpBlockers.isEmpty()) {
|
||||||
getAttackers().shuffle();
|
getAttackers().shuffle();
|
||||||
@@ -644,20 +642,4 @@ public class ComputerUtil_Block2 {
|
|||||||
|
|
||||||
return combat;
|
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