mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Improve discard check
This commit is contained in:
@@ -139,7 +139,7 @@ public class ComputerUtilCost {
|
|||||||
if (source.getAbilityText().contains("Bloodrush")) {
|
if (source.getAbilityText().contains("Bloodrush")) {
|
||||||
continue;
|
continue;
|
||||||
} else if (ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai)
|
} else if (ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai)
|
||||||
&& ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize()) {
|
&& !ai.isUnlimitedHandSize() && ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize()) {
|
||||||
// Better do something than just discard stuff
|
// Better do something than just discard stuff
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public abstract class SpellAbilityAi {
|
|||||||
if (sa.hasParam("AILogic")) {
|
if (sa.hasParam("AILogic")) {
|
||||||
final String logic = sa.getParam("AILogic");
|
final String logic = sa.getParam("AILogic");
|
||||||
final boolean alwaysOnDiscard = "AlwaysOnDiscard".equals(logic) && ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai)
|
final boolean alwaysOnDiscard = "AlwaysOnDiscard".equals(logic) && ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN, ai)
|
||||||
&& ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize();
|
&& !ai.isUnlimitedHandSize() && ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize();
|
||||||
if (!checkAiLogic(ai, sa, logic)) {
|
if (!checkAiLogic(ai, sa, logic)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ public class AttachAi extends SpellAbilityAi {
|
|||||||
|
|
||||||
boolean hasFloatMana = ai.getManaPool().totalMana() > 0;
|
boolean hasFloatMana = ai.getManaPool().totalMana() > 0;
|
||||||
boolean willDiscardNow = game.getPhaseHandler().is(PhaseType.END_OF_TURN, ai)
|
boolean willDiscardNow = game.getPhaseHandler().is(PhaseType.END_OF_TURN, ai)
|
||||||
&& ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize();
|
&& !ai.isUnlimitedHandSize() && ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize();
|
||||||
boolean willDieNow = combat != null && ComputerUtilCombat.lifeInSeriousDanger(ai, combat);
|
boolean willDieNow = combat != null && ComputerUtilCombat.lifeInSeriousDanger(ai, combat);
|
||||||
boolean willRespondToStack = canRespondToStack && MyRandom.percentTrue(chanceToRespondToStack);
|
boolean willRespondToStack = canRespondToStack && MyRandom.percentTrue(chanceToRespondToStack);
|
||||||
boolean willCastEarly = MyRandom.percentTrue(chanceToCastEarly);
|
boolean willCastEarly = MyRandom.percentTrue(chanceToCastEarly);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public abstract class DamageAiBase extends SpellAbilityAi {
|
|||||||
PhaseHandler phase = game.getPhaseHandler();
|
PhaseHandler phase = game.getPhaseHandler();
|
||||||
// If this is a spell, cast it instead of discarding
|
// If this is a spell, cast it instead of discarding
|
||||||
if ((phase.is(PhaseType.END_OF_TURN) || phase.is(PhaseType.MAIN2))
|
if ((phase.is(PhaseType.END_OF_TURN) || phase.is(PhaseType.MAIN2))
|
||||||
&& phase.isPlayerTurn(comp) && (hand.size() > comp.getMaxHandSize())) {
|
&& phase.isPlayerTurn(comp) && hand.size() > comp.getMaxHandSize()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class PermanentCreatureAi extends PermanentAi {
|
|||||||
boolean hasAmbushAI = card.hasSVar("AmbushAI");
|
boolean hasAmbushAI = card.hasSVar("AmbushAI");
|
||||||
boolean defOnlyAmbushAI = hasAmbushAI && "BlockOnly".equals(card.getSVar("AmbushAI"));
|
boolean defOnlyAmbushAI = hasAmbushAI && "BlockOnly".equals(card.getSVar("AmbushAI"));
|
||||||
boolean hasFloatMana = ai.getManaPool().totalMana() > 0;
|
boolean hasFloatMana = ai.getManaPool().totalMana() > 0;
|
||||||
boolean willDiscardNow = isOwnEOT && ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize();
|
boolean willDiscardNow = isOwnEOT && !ai.isUnlimitedHandSize() && ai.getCardsIn(ZoneType.Hand).size() > ai.getMaxHandSize();
|
||||||
boolean willDieNow = combat != null && ComputerUtilCombat.lifeInSeriousDanger(ai, combat);
|
boolean willDieNow = combat != null && ComputerUtilCombat.lifeInSeriousDanger(ai, combat);
|
||||||
boolean wantToCastInMain1 = ph.is(PhaseType.MAIN1, ai) && ComputerUtil.castPermanentInMain1(ai, sa);
|
boolean wantToCastInMain1 = ph.is(PhaseType.MAIN1, ai) && ComputerUtil.castPermanentInMain1(ai, sa);
|
||||||
boolean isCommander = card.isCommander();
|
boolean isCommander = card.isCommander();
|
||||||
|
|||||||
Reference in New Issue
Block a user