Commit 25fc7b77 authored by Michael Kamensky's avatar Michael Kamensky

Merge branch 'master' into 'master'

Minor improvements in Surveil logic.

See merge request core-developers/forge!1072
parents 09b31192 e4bf96d5
......@@ -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"), /** */
......
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;
}
}
......@@ -171,6 +171,9 @@ SCRY_IMMEDIATELY_UNCASTABLE_CMC_DIFF=3
# If the AI has this many or fewer cards in the library, it will Surveil to the top of the library in order
# not to deplete the library.
SURVEIL_NUM_CARDS_IN_LIBRARY_TO_BAIL=10
# If the AI will have less life than the specified percentage as a result of activating a Surveil ability
# that requires a life playment, it will not pay life to activate it (e.g. Doom Whisperer).
SURVEIL_LIFEPERC_AFTER_PAYING_LIFE=75
# Attempt to predict the number of potential blockers with various forms of evasion when
# deciding to do an all-in assault attack
......
......@@ -171,6 +171,9 @@ SCRY_IMMEDIATELY_UNCASTABLE_CMC_DIFF=1
# If the AI has this many or fewer cards in the library, it will Surveil to the top of the library in order
# not to deplete the library.
SURVEIL_NUM_CARDS_IN_LIBRARY_TO_BAIL=10
# If the AI will have less life than the specified percentage as a result of activating a Surveil ability
# that requires a life playment, it will not pay life to activate it (e.g. Doom Whisperer).
SURVEIL_LIFEPERC_AFTER_PAYING_LIFE=60
# Attempt to predict the number of potential blockers with various forms of evasion when
# deciding to do an all-in assault attack
......
......@@ -171,6 +171,9 @@ SCRY_IMMEDIATELY_UNCASTABLE_CMC_DIFF=1
# If the AI has this many or fewer cards in the library, it will Surveil to the top of the library in order
# not to deplete the library.
SURVEIL_NUM_CARDS_IN_LIBRARY_TO_BAIL=8
# If the AI will have less life than the specified percentage as a result of activating a Surveil ability
# that requires a life playment, it will not pay life to activate it (e.g. Doom Whisperer).
SURVEIL_LIFEPERC_AFTER_PAYING_LIFE=50
# Attempt to predict the number of potential blockers with various forms of evasion when
# deciding to do an all-in assault attack (Experimental!)
......
......@@ -171,6 +171,9 @@ SCRY_IMMEDIATELY_UNCASTABLE_CMC_DIFF=1
# If the AI has this many or fewer cards in the library, it will Surveil to the top of the library in order
# not to deplete the library.
SURVEIL_NUM_CARDS_IN_LIBRARY_TO_BAIL=5
# If the AI will have less life than the specified percentage as a result of activating a Surveil ability
# that requires a life playment, it will not pay life to activate it (e.g. Doom Whisperer).
SURVEIL_LIFEPERC_AFTER_PAYING_LIFE=35
# Attempt to predict the number of potential blockers with various forms of evasion when
# deciding to do an all-in assault attack
......
......@@ -4,6 +4,6 @@ Types:Creature Nightmare Demon
PT:6/6
K:Flying
K:Trample
A:AB$ Surveil | Cost$ PayLife<2> | Amount$ 2 | SpellDescription$ Surveil 2. (Look at the top two cards of your library, then put any number of them into your graveyard and the rest on the top of your library in any order.)
A:AB$ Surveil | Cost$ PayLife<2> | Amount$ 2 | AILogic$ Once | SpellDescription$ Surveil 2. (Look at the top two cards of your library, then put any number of them into your graveyard and the rest on the top of your library in any order.)
DeckHas:Ability$Surveil & Ability$Graveyard
Oracle:Flying, trample\nPay 2 life: Surveil 2. (Look at the top two cards of your library, then put any number of them into your graveyard and the rest on the top of your library in any order.)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment