Goad doesn't stack

This commit is contained in:
Bug Hunter
2022-01-23 20:20:35 +00:00
committed by Michael Kamensky
parent f5430b7e26
commit 2b7fb8c5be
10 changed files with 29 additions and 21 deletions

View File

@@ -624,7 +624,7 @@ public class AiAttackController {
// Attempt to see if there's a defined entity that must be attacked strictly this turn...
GameEntity entity = ai.getMustAttackEntityThisTurn();
if (entity == null) {
if (nextTurn || entity == null) {
// ...or during the attacking creature controller's turn
entity = ai.getMustAttackEntity();
}
@@ -720,6 +720,7 @@ public class AiAttackController {
continue;
}
boolean mustAttack = false;
// TODO for nextTurn check if it was temporary
if (attacker.isGoaded()) {
mustAttack = true;
} else if (attacker.getSVar("MustAttack").equals("True")) {
@@ -736,7 +737,7 @@ public class AiAttackController {
mustAttack = true;
}
}
if (mustAttack || attacker.getController().getMustAttackEntity() != null || attacker.getController().getMustAttackEntityThisTurn() != null) {
if (mustAttack || (attacker.getController().getMustAttackEntity() != null && nextTurn) || (attacker.getController().getMustAttackEntityThisTurn() != null && !nextTurn)) {
combat.addAttacker(attacker, defender);
attackersLeft.remove(attacker);
numForcedAttackers++;

View File

@@ -3040,11 +3040,11 @@ public class ComputerUtil {
public static boolean aiLifeInDanger(Player ai, boolean serious, int payment) {
// TODO should also consider them as teams
for (Player opponent: ai.getOpponents()) {
// test whether the human can kill the ai next turn
Combat combat = new Combat(opponent);
boolean containsAttacker = false;
boolean thisCombat = ai.getGame().getPhaseHandler().isPlayerTurn(opponent) && ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN);
for (Card att : opponent.getCreaturesInPlay()) {
if (ComputerUtilCombat.canAttackNextTurn(att, ai)) {
if ((thisCombat && CombatUtil.canAttack(att, ai)) || (!thisCombat && ComputerUtilCombat.canAttackNextTurn(att, ai))) {
combat.addAttacker(att, ai);
containsAttacker = true;
}
@@ -3052,6 +3052,8 @@ public class ComputerUtil {
if (!containsAttacker) {
continue;
}
// TODO if it's next turn ignore mustBlockCards
AiBlockController block = new AiBlockController(ai, false);
block.assignBlockersForCombat(combat);

View File

@@ -39,6 +39,10 @@ public class GoadAi extends SpellAbilityAi {
if (ComputerUtilCard.isUselessCreature(ai, c)) {
return false;
}
// useless
if (c.isGoadedBy(ai)) {
return false;
}
// select creatures which can attack an Opponent other than ai
for (Player o : ai.getOpponents()) {
if (ComputerUtilCombat.canAttackNextTurn(c, o)) {
@@ -64,6 +68,10 @@ public class GoadAi extends SpellAbilityAi {
if (ComputerUtilCard.isUselessCreature(ai, c)) {
return false;
}
// useless
if (c.isGoadedBy(ai)) {
return false;
}
// select only creatures AI can block
return ComputerUtilCard.canBeBlockedProfitably(ai, c, false);
}