Merge branch 'AIHermitDruid' into 'master'

Improves AI logic for Hermit Druid

See merge request core-developers/forge!240
This commit is contained in:
swordshine
2018-03-13 04:09:27 +00:00

View File

@@ -6,6 +6,7 @@ import forge.ai.SpellAbilityAi;
import forge.game.card.Card;
import forge.game.card.CardLists;
import forge.game.card.CardPredicates;
import forge.game.phase.PhaseType;
import forge.game.player.Player;
import forge.game.player.PlayerActionConfirmMode;
import forge.game.spellability.AbilitySub;
@@ -27,6 +28,12 @@ public class DigUntilAi extends SpellAbilityAi {
chance = .667; // 66.7% chance for sorcery speed (since it will
// never activate EOT)
}
// if we don't use anything now, we wasted our opportunity.
if ((ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN))
&& (!ai.getGame().getPhaseHandler().isPlayerTurn(ai))) {
chance = 1;
}
final Random r = MyRandom.getRandom();
final boolean randomReturn = r.nextFloat() <= Math.pow(chance, sa.getActivationsThisTurn() + 1);
@@ -44,9 +51,15 @@ public class DigUntilAi extends SpellAbilityAi {
if ("Land.Basic".equals(sa.getParam("Valid"))
&& !CardLists.filter(ai.getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS_PRODUCING_MANA).isEmpty()) {
// We already have a mana-producing land in hand, so bail
// until opponent's end of turn phase!
// But we still want more (and want to fill grave) if nothing better to do then
// This is important for Replenish/Living Death type decks
if (!((ai.getGame().getPhaseHandler().is(PhaseType.END_OF_TURN))
&& (!ai.getGame().getPhaseHandler().isPlayerTurn(ai)))) {
return false;
}
}
}
if (sa.usesTargeting()) {
sa.resetTargets();