- Added a castSpellInMain1 AI function that currently checks for Cipher subAbilities and BuffedBy SVars.

This commit is contained in:
Sloth
2013-05-15 14:50:41 +00:00
parent 5e4fb591be
commit 848fd460dc
5 changed files with 41 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ SVar:AttackTax:Mode$ CantAttackUnless | ValidCard$ Creature | EffectZone$ Comman
SVar:DBReset:DB$ StoreSVar | SVar$ Y | Type$ Number | Expression$ 0 SVar:DBReset:DB$ StoreSVar | SVar$ Y | Type$ Number | Expression$ 0
SVar:X:Count$xPaid SVar:X:Count$xPaid
SVar:Y:Number$0 SVar:Y:Number$0
SVar:RemAIDeck:True
SVar:Picture:http://www.wizards.com/global/images/magic/general/war_tax.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/war_tax.jpg
Oracle:X U:This turn, creatures can't attack unless their controller pays X for each attacking creature he or she controls. Oracle:X U:This turn, creatures can't attack unless their controller pays X for each attacking creature he or she controls.
SetInfo:MMQ Uncommon SetInfo:MMQ Uncommon

View File

@@ -89,9 +89,7 @@ public class DrawAi extends SpellAbilityAi {
} }
final boolean bFlag = targetAI(ai, sa, false); if (!targetAI(ai, sa, false)) {
if (!bFlag) {
return false; return false;
} }
@@ -104,7 +102,7 @@ public class DrawAi extends SpellAbilityAi {
// Don't use draw abilities before main 2 if possible // Don't use draw abilities before main 2 if possible
if (game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2) if (game.getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
&& !sa.hasParam("ActivationPhases")) { && !sa.hasParam("ActivationPhases") && !ComputerUtil.castSpellInMain1(ai, sa)) {
return false; return false;
} }
if ((!game.getPhaseHandler().getNextTurn().equals(ai) if ((!game.getPhaseHandler().getNextTurn().equals(ai)

View File

@@ -181,7 +181,7 @@ public abstract class TapAiBase extends SpellAbilityAi {
List<Card> creatureList = CardLists.filter(tapList, findBlockers); List<Card> creatureList = CardLists.filter(tapList, findBlockers);
if (!attackers.isEmpty() && !creatureList.isEmpty()) { if (!attackers.isEmpty() && !creatureList.isEmpty()) {
choice = ComputerUtilCard.getBestCreatureAI(creatureList); choice = ComputerUtilCard.getBestCreatureAI(creatureList);
} else if (sa.isTrigger()) { } else if (sa.isTrigger() || ComputerUtil.castSpellInMain1(ai, sa)) {
choice = ComputerUtilCard.getMostExpensivePermanentAI(tapList, sa, false); choice = ComputerUtilCard.getMostExpensivePermanentAI(tapList, sa, false);
} }

View File

@@ -105,7 +105,8 @@ public class TokenAi extends SpellAbilityAi {
// Don't generate tokens without haste before main 2 if possible // Don't generate tokens without haste before main 2 if possible
if (ph.getPhase().isBefore(PhaseType.MAIN2) if (ph.getPhase().isBefore(PhaseType.MAIN2)
&& ph.isPlayerTurn(ai) && !haste && ph.isPlayerTurn(ai) && !haste
&& !sa.hasParam("ActivationPhases")) { && !sa.hasParam("ActivationPhases")
&& !ComputerUtil.castSpellInMain1(ai, sa)) {
return false; return false;
} }
if ((ph.isPlayerTurn(ai) if ((ph.isPlayerTurn(ai)

View File

@@ -1001,6 +1001,41 @@ public class ComputerUtil {
|| !ph.getNextTurn().equals(sa.getActivatingPlayer()))); || !ph.getNextTurn().equals(sa.getActivatingPlayer())));
} }
/**
* <p>
* castSpellMain1.
* </p>
*
* @param sa
* a {@link forge.card.spellability.SpellAbility} object.
* @return a boolean (returns true if it's better to wait until blockers are declared).
*/
public static boolean castSpellInMain1(final Player ai, final SpellAbility sa) {
final Card source = sa.getSourceCard();
final SpellAbility sub = sa.getSubAbility();
// Cipher spells
if (sub != null && ApiType.Encode == sa.getSubAbility().getApi() && !ai.getCreaturesInPlay().isEmpty()) {
return true;
}
final List<Card> buffed = ai.getCardsIn(ZoneType.Battlefield);
for (Card buffedcard : buffed) {
if (buffedcard.hasSVar("BuffedBy")) {
final String buffedby = buffedcard.getSVar("BuffedBy");
final String[] bffdby = buffedby.split(",");
if (source.isValid(bffdby, buffedcard.getController(), buffedcard)) {
return true;
}
}
}
if (sub != null) {
return castSpellInMain1(ai, sub);
}
return false;
}
// returns true if the AI should stop using the ability // returns true if the AI should stop using the ability
/** /**
* <p> * <p>