- FogAi update from Seravy (updated for style consistency).

This commit is contained in:
Agetian
2018-04-30 09:36:31 +03:00
parent 5049b7885a
commit 9aec30e0dc
2 changed files with 8 additions and 15 deletions

View File

@@ -40,8 +40,6 @@ import forge.util.Expressions;
import forge.util.MyRandom;
import forge.util.collect.FCollectionView;
import static forge.ai.AiCardMemory.isMemorySetEmpty;
import java.util.ArrayList;
import java.util.List;
@@ -265,8 +263,8 @@ public class AiAttackController {
if (ai.getGame().getPhaseHandler().getNextTurn().equals(ai)) {
return attackers;
}
// no need to block is already holding mana to cast fog next turn
if (!isMemorySetEmpty(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT)) {
// no need to block (already holding mana to cast fog next turn)
if (!AiCardMemory.isMemorySetEmpty(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT)) {
// Don't send the card that'll do the fog effect to attack, it's unsafe!
if (attackers.contains(AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT)) {
attackers.remove(AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT);

View File

@@ -30,11 +30,9 @@ public class FogAi extends SpellAbilityAi {
// if card would be destroyed, react and use immediately if it's not own turn
if ((AiCardMemory.isRememberedCard(ai, hostCard, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT))
&& (!game.getStack().isEmpty()) &&
(!game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer()))
) {
final List<GameObject> objects = ComputerUtil
.predictThreatenedObjects(ai, null);
&& (!game.getStack().isEmpty())
&& (!game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer()))) {
final List<GameObject> objects = ComputerUtil.predictThreatenedObjects(ai, null);
if (objects.contains(hostCard)) {
AiCardMemory.clearMemorySet(ai, AiCardMemory.MemorySet.HELD_MANA_SOURCES_FOR_ENEMY_DECLBLK);
return true;
@@ -42,15 +40,12 @@ public class FogAi extends SpellAbilityAi {
}
// Reserve mana to cast this card if it will be likely needed
if (((game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer())) ||
(game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)))
if (((game.getPhaseHandler().isPlayerTurn(sa.getActivatingPlayer()))
|| (game.getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_DECLARE_BLOCKERS)))
&& (AiCardMemory.isMemorySetEmpty(ai, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT))
&& (ComputerUtil.aiLifeInDanger(ai, false, 0))
) {
&& (ComputerUtil.aiLifeInDanger(ai, false, 0))) {
((PlayerControllerAi) ai.getController()).getAi().reserveManaSources(sa, PhaseType.COMBAT_DECLARE_BLOCKERS, true);
AiCardMemory.rememberCard(ai, hostCard, AiCardMemory.MemorySet.CHOSEN_FOG_EFFECT);
}
// AI should only activate this during Human's Declare Blockers phase