mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
AI: cleanup for AI to play Foretell cards
This commit is contained in:
committed by
Michael Kamensky
parent
76a2899769
commit
a83fc18d92
@@ -81,18 +81,7 @@ public class ComputerUtilAbility {
|
||||
public static List<SpellAbility> getSpellAbilities(final CardCollectionView l, final Player player) {
|
||||
final List<SpellAbility> spellAbilities = Lists.newArrayList();
|
||||
for (final Card c : l) {
|
||||
for (final SpellAbility sa : c.getSpellAbilities()) {
|
||||
// Spells of permanents can't be activated on the battlefield
|
||||
if (c.isPermanent() && sa.isSpell() && c.isInZone(ZoneType.Battlefield)) {
|
||||
continue;
|
||||
}
|
||||
spellAbilities.add(sa);
|
||||
}
|
||||
if (c.isFaceDown() && c.isInZone(ZoneType.Exile) && !c.mayPlay(player).isEmpty()) {
|
||||
for (final SpellAbility sa : c.getState(CardStateName.Original).getSpellAbilities()) {
|
||||
spellAbilities.add(sa);
|
||||
}
|
||||
}
|
||||
spellAbilities.addAll(c.getAllPossibleAbilities(player, false));
|
||||
}
|
||||
return spellAbilities;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.util.Lang;
|
||||
import forge.util.TextUtil;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
@@ -176,13 +177,8 @@ public final class GameActionUtil {
|
||||
desc.append(newSA.getCostDescription());
|
||||
desc.append("(").append(inst.getReminderText()).append(")");
|
||||
newSA.setDescription(desc.toString());
|
||||
newSA.putParam("AfterDescription", "(Escaped)");
|
||||
|
||||
// Stack Description only for Permanent or it might crash
|
||||
if (source.isPermanent()) {
|
||||
final StringBuilder sbStack = new StringBuilder();
|
||||
sbStack.append(sa.getStackDescription()).append(" (Escaped)");
|
||||
newSA.setStackDescription(sbStack.toString());
|
||||
}
|
||||
newSA.setAlternativeCost(AlternativeCost.Escape);
|
||||
newSA.getRestrictions().setZone(ZoneType.Graveyard);
|
||||
|
||||
@@ -217,13 +213,7 @@ public final class GameActionUtil {
|
||||
final SpellAbility foretold = sa.copy(activator);
|
||||
foretold.setAlternativeCost(AlternativeCost.Foretold);
|
||||
foretold.getRestrictions().setZone(ZoneType.Exile);
|
||||
|
||||
// Stack Description only for Permanent or it might crash
|
||||
if (source.isPermanent()) {
|
||||
final StringBuilder sbStack = new StringBuilder();
|
||||
sbStack.append(sa.getStackDescription()).append(" (Foretold)");
|
||||
foretold.setStackDescription(sbStack.toString());
|
||||
}
|
||||
foretold.putParam("AfterDescription", "(Foretold)");
|
||||
|
||||
final String[] k = keyword.split(":");
|
||||
foretold.setPayCosts(new Cost(k[1], false));
|
||||
|
||||
@@ -97,11 +97,15 @@ public abstract class SpellAbilityEffect {
|
||||
}
|
||||
} else {
|
||||
final String conditionDesc = sa.getParam("ConditionDescription");
|
||||
final String afterDesc = sa.getParam("AfterDescription");
|
||||
final String baseDesc = this.getStackDescription(sa);
|
||||
if (conditionDesc != null) {
|
||||
sb.append(conditionDesc).append(" ");
|
||||
}
|
||||
sb.append(baseDesc);
|
||||
if (afterDesc != null) {
|
||||
sb.append(" ").append(afterDesc);
|
||||
}
|
||||
}
|
||||
|
||||
// only add to StackDescription if its not a Permanent Spell
|
||||
|
||||
@@ -33,7 +33,7 @@ public class CostAdjustment {
|
||||
final Card host = sa.getHostCard();
|
||||
final Game game = player.getGame();
|
||||
|
||||
if (sa.isTrigger()) {
|
||||
if (sa.isTrigger() || cost == null) {
|
||||
return cost;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ package forge.game.spellability;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
||||
import forge.card.CardStateName;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.cost.Cost;
|
||||
@@ -30,7 +31,7 @@ import forge.game.zone.ZoneType;
|
||||
public class LandAbility extends Ability {
|
||||
|
||||
public LandAbility(Card sourceCard, Player p, StaticAbility mayPlay) {
|
||||
super(sourceCard, (Cost)null);
|
||||
super(sourceCard, new Cost(ManaCost.NO_COST, false));
|
||||
setActivatingPlayer(p);
|
||||
setMayPlay(mayPlay);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user