mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
- Adding a way to suppress testing canRegenerate from combat code temporarily to avoid re-entry from ComputerUtil#canRegenerate when testing cards such as Varolz, the Scar-Striped.
This commit is contained in:
@@ -810,6 +810,9 @@ public class ComputerUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean canRegen = false;
|
||||||
|
ComputerUtilCombat.setCombatRegenTestSuppression(true); // do not check canRegenerate recursively from combat code
|
||||||
|
|
||||||
final Player controller = card.getController();
|
final Player controller = card.getController();
|
||||||
final Game game = controller.getGame();
|
final Game game = controller.getGame();
|
||||||
final CardCollectionView l = controller.getCardsIn(ZoneType.Battlefield);
|
final CardCollectionView l = controller.getCardsIn(ZoneType.Battlefield);
|
||||||
@@ -846,10 +849,10 @@ public class ComputerUtil {
|
|||||||
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
final TargetRestrictions tgt = sa.getTargetRestrictions();
|
||||||
if (tgt != null) {
|
if (tgt != null) {
|
||||||
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard(), sa).contains(card)) {
|
if (CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), tgt.getValidTgts(), controller, sa.getHostCard(), sa).contains(card)) {
|
||||||
return true;
|
canRegen = true;
|
||||||
}
|
}
|
||||||
} else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
|
} else if (AbilityUtils.getDefinedCards(sa.getHostCard(), sa.getParam("Defined"), sa).contains(card)) {
|
||||||
return true;
|
canRegen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
@@ -857,7 +860,9 @@ public class ComputerUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
ComputerUtilCombat.setCombatRegenTestSuppression(false);
|
||||||
|
return canRegen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int possibleDamagePrevention(final Card card) {
|
public static int possibleDamagePrevention(final Card card) {
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ import forge.util.collect.FCollection;
|
|||||||
*/
|
*/
|
||||||
public class ComputerUtilCombat {
|
public class ComputerUtilCombat {
|
||||||
|
|
||||||
|
// A special flag used in ComputerUtil#canRegenerate to avoid recursive reentry and stack overflow
|
||||||
|
private static boolean dontTestRegen = false;
|
||||||
|
public static void setCombatRegenTestSuppression(boolean shouldSuppress) {
|
||||||
|
dontTestRegen = shouldSuppress;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* canAttackNextTurn.
|
* canAttackNextTurn.
|
||||||
@@ -1840,7 +1846,7 @@ public class ComputerUtilCombat {
|
|||||||
}
|
}
|
||||||
} // flanking
|
} // flanking
|
||||||
|
|
||||||
if (blocker.hasKeyword("Indestructible") || ComputerUtil.canRegenerate(blocker.getController(), blocker)) {
|
if (blocker.hasKeyword("Indestructible") || dontTestRegen || ComputerUtil.canRegenerate(blocker.getController(), blocker)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user