mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- The AI can now play static abilities in general.
- The AI can now activate Suspend abilities. It's experimental, so please check each card before removing SVar:RemAIDeck:True.
This commit is contained in:
@@ -39,6 +39,7 @@ import forge.card.mana.ManaCost;
|
||||
import forge.card.replacement.ReplacementEffect;
|
||||
import forge.card.spellability.AbilityMana;
|
||||
import forge.card.spellability.AbilityTriggered;
|
||||
import forge.card.spellability.Spell;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.SpellPermanent;
|
||||
import forge.card.staticability.StaticAbility;
|
||||
@@ -1560,7 +1561,27 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
c.getSpellAbility()[0].setActivatingPlayer(c.getOwner());
|
||||
// Any trigger should cause the phase not to skip
|
||||
AllZone.getPhaseHandler().setSkipPhase(false);
|
||||
AllZone.getGameAction().playCardNoCost(c);
|
||||
if(c.getOwner().isHuman()) {
|
||||
AllZone.getGameAction().playCardNoCost(c);
|
||||
} else {
|
||||
final ArrayList<SpellAbility> choices = this.getBasicSpells();
|
||||
|
||||
for (final SpellAbility sa : choices) {
|
||||
//Spells
|
||||
if (sa instanceof Spell) {
|
||||
Spell spell = (Spell) sa;
|
||||
if (!spell.canPlayFromEffectAI(false, true)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (!sa.canPlayAI()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ComputerUtil.playSpellAbilityWithoutPayingManaCost(sa);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import forge.card.cost.CostUtil;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaPool;
|
||||
import forge.card.spellability.AbilityMana;
|
||||
import forge.card.spellability.AbilityStatic;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.card.spellability.Target;
|
||||
import forge.error.ErrorViewer;
|
||||
@@ -51,7 +52,7 @@ public class ComputerUtil {
|
||||
// if return true, go to next phase
|
||||
/**
|
||||
* <p>
|
||||
* playCards.
|
||||
* playSpellAbilities.
|
||||
* </p>
|
||||
*
|
||||
* @param all
|
||||
@@ -123,7 +124,9 @@ public class ComputerUtil {
|
||||
if ((!flashb || source.hasStartOfKeyword("May be played")) && ComputerUtil.canBePlayedAndPayedByAI(sa)) {
|
||||
ComputerUtil.handlePlayingSpellAbility(sa);
|
||||
|
||||
return false;
|
||||
if (!(sa instanceof AbilityStatic)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -131,7 +134,7 @@ public class ComputerUtil {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* playCards.
|
||||
* playAbilities.
|
||||
* </p>
|
||||
*
|
||||
* @param all
|
||||
@@ -155,6 +158,14 @@ public class ComputerUtil {
|
||||
* a {@link forge.card.spellability.SpellAbility} object.
|
||||
*/
|
||||
public static void handlePlayingSpellAbility(final SpellAbility sa) {
|
||||
|
||||
if (sa instanceof AbilityStatic) {
|
||||
if (ComputerUtil.payManaCost(sa, AllZone.getComputerPlayer(), false, 0)) {
|
||||
sa.resolve();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
AllZone.getStack().freezeStack();
|
||||
final Card source = sa.getSourceCard();
|
||||
|
||||
|
||||
@@ -1267,7 +1267,7 @@ public class CardFactoryUtil {
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return false;
|
||||
return true;
|
||||
// Suspend currently not functional for the AI,
|
||||
// seems to be an issue with regaining Priority after Suspension
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user