- Added canPlayFromEffectAI function.

This commit is contained in:
Sloth
2012-01-14 11:39:59 +00:00
parent c6df9138d2
commit ebece034b9
3 changed files with 35 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ import forge.card.abilityfactory.AbilityFactory;
import forge.card.cardfactory.CardFactoryUtil;
import forge.card.spellability.Ability;
import forge.card.spellability.AbilityMana;
import forge.card.spellability.Spell;
import forge.card.spellability.SpellAbility;
import forge.game.GameLossReason;
import forge.gui.GuiUtils;
@@ -155,14 +156,23 @@ public final class GameActionUtil {
final ArrayList<SpellAbility> choices = cascadedCard.getBasicSpells();
for (final SpellAbility sa : choices) {
if (sa.canPlayAI() || sa.doTrigger(false)) {
//Spells
if (sa instanceof Spell) {
Spell spell = (Spell) sa;
if (!spell.canPlayFromEffectAI(false, true)) {
continue;
}
} else {
if (!sa.canPlayAI()) {
continue;
}
}
ComputerUtil.playStackFree(sa);
revealed.remove(cascadedCard);
break;
}
}
}
}
revealed.shuffle();
for (final Card bottom : revealed) {
AllZone.getGameAction().moveToBottomOfLibrary(bottom);

View File

@@ -140,10 +140,14 @@ public class AbilityFactoryDealDamage {
}
@Override
public boolean doTrigger(final boolean mandatory) {
public boolean canPlayFromEffectAI(final boolean mandatory, final boolean withOutManaCost) {
if (withOutManaCost) {
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAINoCost(
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
}
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
}
}; // Spell
return spDealDamage;

View File

@@ -153,4 +153,19 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
throw new RuntimeException("Spell : clone() error, " + ex);
}
}
/**
* <p>
* canPlayFromEffectAI.
* </p>
*
* @param mandatory
* can the controller chose not to play the spell
* @param withOutManaCost
* is the spell cast without paying mana
* @return a boolean.
*/
public boolean canPlayFromEffectAI(boolean mandatory, boolean withOutManaCost) {
return canPlayAI();
}
}