- Minor improvements in Surveil logic.

This commit is contained in:
Agetian
2018-11-08 08:47:19 +03:00
parent ebbde37929
commit 44de14d070
8 changed files with 37 additions and 5 deletions

View File

@@ -96,6 +96,7 @@ public enum AiProps { /** */
SCRY_IMMEDIATELY_UNCASTABLE_TO_BOTTOM ("false"), /** */
SCRY_IMMEDIATELY_UNCASTABLE_CMC_DIFF ("1"), /** */
SURVEIL_NUM_CARDS_IN_LIBRARY_TO_BAIL ("10"), /** */
SURVEIL_LIFEPERC_AFTER_PAYING_LIFE ("75"), /** */
COMBAT_ASSAULT_ATTACK_EVASION_PREDICTION ("true"), /** */
COMBAT_ATTRITION_ATTACK_EVASION_PREDICTION ("true"), /** */
CONSERVATIVE_ENERGY_PAYMENT_ONLY_IN_COMBAT ("true"), /** */

View File

@@ -1,6 +1,9 @@
package forge.ai.ability;
import forge.ai.SpellAbilityAi;
import forge.ai.*;
import forge.game.card.Card;
import forge.game.cost.Cost;
import forge.game.cost.CostPayLife;
import forge.game.phase.PhaseHandler;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
@@ -68,8 +71,14 @@ public class SurveilAi extends SpellAbilityAi {
*/
@Override
protected boolean checkAiLogic(final Player ai, final SpellAbility sa, final String aiLogic) {
final Card source = sa.getHostCard();
if ("Never".equals(aiLogic)) {
return false;
} else if ("Once".equals(aiLogic)) {
if (AiCardMemory.isRememberedCard(ai, source, AiCardMemory.MemorySet.ACTIVATED_THIS_TURN)) {
return false;
}
}
// TODO: add card-specific Surveil AI logic here when/if necessary
@@ -84,6 +93,15 @@ public class SurveilAi extends SpellAbilityAi {
return false;
}
// Only Surveil for life when at decent amount of life remaining
final Cost cost = sa.getPayCosts();
if (cost != null && cost.hasSpecificCostType(CostPayLife.class)) {
final int maxLife = ((PlayerControllerAi)ai.getController()).getAi().getIntProperty(AiProps.SURVEIL_LIFEPERC_AFTER_PAYING_LIFE);
if (!ComputerUtilCost.checkLifeCost(ai, cost, sa.getHostCard(), ai.getStartingLife() * maxLife / 100, sa)) {
return false;
}
}
double chance = .4; // 40 percent chance for instant speed
if (SpellAbilityAi.isSorcerySpeed(sa)) {
chance = .667; // 66.7% chance for sorcery speed (since it will never activate EOT)
@@ -99,6 +117,7 @@ public class SurveilAi extends SpellAbilityAi {
@Override
public boolean confirmAction(Player player, SpellAbility sa, PlayerActionConfirmMode mode, String message) {
AiCardMemory.rememberCard(player, sa.getHostCard(), AiCardMemory.MemorySet.ACTIVATED_THIS_TURN);
return true;
}
}