Improves AI logic for Hermit Druid

-Will now use at end of enemy turn at 100% chance instead of wasting opportunity to get land and fill grave

Not sure if "RemRandomDeck" is still needed? Card is now safe to play unless the deck has fewer than 4-5 basic lands in it.
This commit is contained in:
Seravy
2018-02-13 11:17:46 +01:00
parent 2ff32d3b90
commit 2b688a99ff

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,7 +51,13 @@ 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
return false;
// 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;
}
}
}