mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +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) {
|
public static List<SpellAbility> getSpellAbilities(final CardCollectionView l, final Player player) {
|
||||||
final List<SpellAbility> spellAbilities = Lists.newArrayList();
|
final List<SpellAbility> spellAbilities = Lists.newArrayList();
|
||||||
for (final Card c : l) {
|
for (final Card c : l) {
|
||||||
for (final SpellAbility sa : c.getSpellAbilities()) {
|
spellAbilities.addAll(c.getAllPossibleAbilities(player, false));
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return spellAbilities;
|
return spellAbilities;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import forge.game.trigger.TriggerType;
|
|||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.util.Lang;
|
import forge.util.Lang;
|
||||||
import forge.util.TextUtil;
|
import forge.util.TextUtil;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -176,13 +177,8 @@ public final class GameActionUtil {
|
|||||||
desc.append(newSA.getCostDescription());
|
desc.append(newSA.getCostDescription());
|
||||||
desc.append("(").append(inst.getReminderText()).append(")");
|
desc.append("(").append(inst.getReminderText()).append(")");
|
||||||
newSA.setDescription(desc.toString());
|
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.setAlternativeCost(AlternativeCost.Escape);
|
||||||
newSA.getRestrictions().setZone(ZoneType.Graveyard);
|
newSA.getRestrictions().setZone(ZoneType.Graveyard);
|
||||||
|
|
||||||
@@ -217,13 +213,7 @@ public final class GameActionUtil {
|
|||||||
final SpellAbility foretold = sa.copy(activator);
|
final SpellAbility foretold = sa.copy(activator);
|
||||||
foretold.setAlternativeCost(AlternativeCost.Foretold);
|
foretold.setAlternativeCost(AlternativeCost.Foretold);
|
||||||
foretold.getRestrictions().setZone(ZoneType.Exile);
|
foretold.getRestrictions().setZone(ZoneType.Exile);
|
||||||
|
foretold.putParam("AfterDescription", "(Foretold)");
|
||||||
// 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
final String[] k = keyword.split(":");
|
final String[] k = keyword.split(":");
|
||||||
foretold.setPayCosts(new Cost(k[1], false));
|
foretold.setPayCosts(new Cost(k[1], false));
|
||||||
|
|||||||
@@ -97,11 +97,15 @@ public abstract class SpellAbilityEffect {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final String conditionDesc = sa.getParam("ConditionDescription");
|
final String conditionDesc = sa.getParam("ConditionDescription");
|
||||||
|
final String afterDesc = sa.getParam("AfterDescription");
|
||||||
final String baseDesc = this.getStackDescription(sa);
|
final String baseDesc = this.getStackDescription(sa);
|
||||||
if (conditionDesc != null) {
|
if (conditionDesc != null) {
|
||||||
sb.append(conditionDesc).append(" ");
|
sb.append(conditionDesc).append(" ");
|
||||||
}
|
}
|
||||||
sb.append(baseDesc);
|
sb.append(baseDesc);
|
||||||
|
if (afterDesc != null) {
|
||||||
|
sb.append(" ").append(afterDesc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only add to StackDescription if its not a Permanent Spell
|
// only add to StackDescription if its not a Permanent Spell
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class CostAdjustment {
|
|||||||
final Card host = sa.getHostCard();
|
final Card host = sa.getHostCard();
|
||||||
final Game game = player.getGame();
|
final Game game = player.getGame();
|
||||||
|
|
||||||
if (sa.isTrigger()) {
|
if (sa.isTrigger() || cost == null) {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.game.spellability;
|
|||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
|
import forge.card.mana.ManaCost;
|
||||||
import forge.game.card.Card;
|
import forge.game.card.Card;
|
||||||
import forge.game.card.CardUtil;
|
import forge.game.card.CardUtil;
|
||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
@@ -30,7 +31,7 @@ import forge.game.zone.ZoneType;
|
|||||||
public class LandAbility extends Ability {
|
public class LandAbility extends Ability {
|
||||||
|
|
||||||
public LandAbility(Card sourceCard, Player p, StaticAbility mayPlay) {
|
public LandAbility(Card sourceCard, Player p, StaticAbility mayPlay) {
|
||||||
super(sourceCard, (Cost)null);
|
super(sourceCard, new Cost(ManaCost.NO_COST, false));
|
||||||
setActivatingPlayer(p);
|
setActivatingPlayer(p);
|
||||||
setMayPlay(mayPlay);
|
setMayPlay(mayPlay);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user