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.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.spellability.Ability;
|
import forge.card.spellability.Ability;
|
||||||
import forge.card.spellability.AbilityMana;
|
import forge.card.spellability.AbilityMana;
|
||||||
|
import forge.card.spellability.Spell;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GameLossReason;
|
import forge.game.GameLossReason;
|
||||||
import forge.gui.GuiUtils;
|
import forge.gui.GuiUtils;
|
||||||
@@ -155,11 +156,20 @@ public final class GameActionUtil {
|
|||||||
final ArrayList<SpellAbility> choices = cascadedCard.getBasicSpells();
|
final ArrayList<SpellAbility> choices = cascadedCard.getBasicSpells();
|
||||||
|
|
||||||
for (final SpellAbility sa : choices) {
|
for (final SpellAbility sa : choices) {
|
||||||
if (sa.canPlayAI() || sa.doTrigger(false)) {
|
//Spells
|
||||||
ComputerUtil.playStackFree(sa);
|
if (sa instanceof Spell) {
|
||||||
revealed.remove(cascadedCard);
|
Spell spell = (Spell) sa;
|
||||||
break;
|
if (!spell.canPlayFromEffectAI(false, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!sa.canPlayAI()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ComputerUtil.playStackFree(sa);
|
||||||
|
revealed.remove(cascadedCard);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,8 +140,12 @@ public class AbilityFactoryDealDamage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doTrigger(final boolean mandatory) {
|
public boolean canPlayFromEffectAI(final boolean mandatory, final boolean withOutManaCost) {
|
||||||
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAINoCost(
|
if (withOutManaCost) {
|
||||||
|
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAINoCost(
|
||||||
|
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
|
||||||
|
}
|
||||||
|
return AbilityFactoryDealDamage.this.dealDamageDoTriggerAI(
|
||||||
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
|
AbilityFactoryDealDamage.this.abilityFactory, this, mandatory);
|
||||||
}
|
}
|
||||||
}; // Spell
|
}; // Spell
|
||||||
|
|||||||
@@ -153,4 +153,19 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
|
|||||||
throw new RuntimeException("Spell : clone() error, " + ex);
|
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