- Default max number of planar die rolls per turn for the AI is 1. The AI will prefer to roll the planar die in Main 2 unless the AIHintRollDieInMain1:True AI hint SVar is set.

This commit is contained in:
Agetian
2013-07-04 14:10:28 +00:00
parent a5887f7dd6
commit 00977986df

View File

@@ -4,6 +4,7 @@ package forge.card.ability.ai;
import forge.Card; import forge.Card;
import forge.card.ability.SpellAbilityAi; import forge.card.ability.SpellAbilityAi;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import forge.game.phase.PhaseType;
import forge.game.player.Player; import forge.game.player.Player;
import forge.util.MyRandom; import forge.util.MyRandom;
@@ -12,9 +13,16 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
* @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility) * @see forge.card.abilityfactory.SpellAiLogic#canPlayAI(forge.game.player.Player, java.util.Map, forge.card.spellability.SpellAbility)
*/ */
@Override @Override
protected boolean canPlayAI(Player aiPlayer, SpellAbility sa) { protected boolean canPlayAI(Player ai, SpellAbility sa) {
Card plane = sa.getSourceCard(); Card plane = sa.getSourceCard();
boolean decideToRoll = false; boolean decideToRoll = false;
int maxActivations = 1;
if (ai.getGame().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) && !plane.hasSVar("AIHintRollDieInMain1")) {
return false;
} else if (plane.hasSVar("AIHintRollDieInMain1") && (plane.getSVar("AIHintRollDieInMain1").toLowerCase().equals("false"))) {
return false;
}
if (plane.hasSVar("AIHintRollDie")) { if (plane.hasSVar("AIHintRollDie")) {
switch (plane.getSVar("AIHintRollDie")) { switch (plane.getSVar("AIHintRollDie")) {
@@ -37,9 +45,11 @@ public class RollPlanarDiceAi extends SpellAbilityAi {
} }
if (plane.hasSVar("AIHintRollDieMaxPerTurn")) { if (plane.hasSVar("AIHintRollDieMaxPerTurn")) {
if (sa.getActivationsThisTurn() > Integer.parseInt(plane.getSVar("AIHintRollDieMaxPerTurn"))) { maxActivations = Integer.parseInt(plane.getSVar("AIHintRollDieMaxPerTurn"));
decideToRoll = false; }
} System.out.println("Activations so far: " + sa.getActivationsThisTurn());
if (sa.getActivationsThisTurn() >= maxActivations) {
decideToRoll = false;
} }
return decideToRoll ? true : false; return decideToRoll ? true : false;