This commit is contained in:
Anthony Calosa
2023-10-21 06:52:57 +08:00
parent b598029112
commit 2bda61da98
3 changed files with 9 additions and 17 deletions

View File

@@ -89,6 +89,7 @@ public class AiController {
private boolean useSimulation;
private SpellAbilityPicker simPicker;
private int lastAttackAggression;
private boolean useLivingEnd;
public AiController(final Player computerPlayer, final Game game0) {
player = computerPlayer;
@@ -1573,7 +1574,7 @@ public class AiController {
}
});
//update LivingEndPlayer
player.setHasLivingEnd(CardLists.filter(player.getZone(ZoneType.Library).getCards(), c-> "Living End".equalsIgnoreCase(c.getName())).size() > 0);
useLivingEnd = Iterables.any(player.getZone(ZoneType.Library), CardPredicates.nameEquals("Living End"));
SpellAbility chosenSa = chooseSpellAbilityToPlayFromList(saList, true);
@@ -1597,7 +1598,7 @@ public class AiController {
Sentry.captureMessage(ex.getMessage() + "\nAssertionError [verifyTransitivity]: " + assertex);
}
//avoid ComputerUtil.aiLifeInDanger in loops as it slows down a lot.. call this outside loops will generally be fast...
boolean isLifeInDanger = player.isLivingEnd() && ComputerUtil.aiLifeInDanger(player, true, 0);
boolean isLifeInDanger = useLivingEnd && ComputerUtil.aiLifeInDanger(player, true, 0);
for (final SpellAbility sa : ComputerUtilAbility.getOriginalAndAltCostAbilities(all, player)) {
// Don't add Counterspells to the "normal" playcard lookups
if (skipCounter && sa.getApi() == ApiType.Counter) {
@@ -1614,7 +1615,7 @@ public class AiController {
}
//living end AI decks
AiPlayDecision aiPlayDecision = AiPlayDecision.CantPlaySa;
if (player.isLivingEnd()) {
if (useLivingEnd) {
if (sa.isCycling() && sa.canCastTiming(player)) {
if (ComputerUtilCost.canPayCost(sa, player, sa.isTrigger()))
aiPlayDecision = AiPlayDecision.WillPlay;
@@ -1640,7 +1641,7 @@ public class AiController {
sa.setLastStateGraveyard(game.getLastStateGraveyard());
}
//override decision for living end player
AiPlayDecision opinion = player.isLivingEnd() && AiPlayDecision.WillPlay.equals(aiPlayDecision) ? aiPlayDecision : canPlayAndPayFor(sa);
AiPlayDecision opinion = useLivingEnd && AiPlayDecision.WillPlay.equals(aiPlayDecision) ? aiPlayDecision : canPlayAndPayFor(sa);
// reset LastStateBattlefield
sa.clearLastState();

View File

@@ -2146,11 +2146,10 @@ public class ComputerUtil {
final int handSize = handList.size();
final int landSize = lands.size();
int score = handList.size();
if (ai.isLivingEnd()) {
//adjust score for Living End decks
final CardCollectionView livingEnd = CardLists.filter(handList, c -> "Living End".equalsIgnoreCase(c.getName()));
if (livingEnd.size() > 0)
score = -(livingEnd.size() * 10);
}
if (handSize/2 == landSize || handSize/2 == landSize +1) {
score += 10;

View File

@@ -168,7 +168,6 @@ public class Player extends GameEntity implements Comparable<Player> {
private int maxHandSize = 7;
private int startingHandSize = 7;
private boolean unlimitedHandSize = false;
private boolean hasLivingEnd = false;
private Card lastDrawnCard;
private Card ringBearer, theRing;
private String namedCard = "";
@@ -456,13 +455,6 @@ public class Player extends GameEntity implements Comparable<Player> {
return isOpponentOf(otherPlayer);
}
public boolean isLivingEnd() {
return hasLivingEnd;
}
public void setHasLivingEnd(boolean value) {
hasLivingEnd = value;
}
public final boolean setLife(final int newLife, final SpellAbility sa) {
boolean change = false;
// rule 119.5