mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Added canPlayFromEffectAI function.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user