mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
AiController: move more to PermanentAi
This commit is contained in:
@@ -70,9 +70,7 @@ import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
import forge.game.replacement.ReplaceMoved;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.spellability.Ability;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.AbilityStatic;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.OptionalCost;
|
||||
import forge.game.spellability.Spell;
|
||||
@@ -682,19 +680,6 @@ public class AiController {
|
||||
return AiPlayDecision.CurseEffects;
|
||||
}
|
||||
if (sa instanceof SpellPermanent) {
|
||||
// don't play cards without being able to pay the upkeep for
|
||||
for (String ability : card.getKeywords()) {
|
||||
if (ability.startsWith("At the beginning of your upkeep, sacrifice CARDNAME unless you pay")) {
|
||||
final String[] k = ability.split(" pay ");
|
||||
final String costs = k[1].replaceAll("[{]", "").replaceAll("[}]", " ");
|
||||
Cost cost = new Cost(costs, true);
|
||||
final Ability emptyAbility = new AbilityStatic(card, cost, sa.getTargetRestrictions()) { @Override public void resolve() { } };
|
||||
emptyAbility.setActivatingPlayer(player);
|
||||
if (!ComputerUtilCost.canPayCost(emptyAbility, player)) {
|
||||
return AiPlayDecision.AnotherTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
return canPlayFromEffectAI((SpellPermanent)sa, false, true);
|
||||
}
|
||||
if (sa instanceof Spell) {
|
||||
@@ -862,7 +847,7 @@ public class AiController {
|
||||
min = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// look for good discards
|
||||
while (count < min) {
|
||||
Card prefCard = null;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.ai.ability;
|
||||
|
||||
import forge.ai.ComputerUtil;
|
||||
import forge.ai.ComputerUtilCost;
|
||||
import forge.ai.ComputerUtilMana;
|
||||
import forge.ai.SpellAbilityAi;
|
||||
import forge.card.CardType.Supertype;
|
||||
@@ -11,6 +12,7 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
@@ -131,6 +133,23 @@ public class PermanentAi extends SpellAbilityAi {
|
||||
}
|
||||
}
|
||||
|
||||
// don't play cards without being able to pay the upkeep for
|
||||
for (String ability : card.getKeywords()) {
|
||||
if (ability.startsWith("At the beginning of your upkeep, sacrifice CARDNAME unless you pay")) {
|
||||
final String[] k = ability.split(" pay ");
|
||||
final String costs = k[1].replaceAll("[{]", "").replaceAll("[}]", " ");
|
||||
|
||||
final SpellAbility emptyAbility = new SpellAbility.EmptySa(card, ai);
|
||||
emptyAbility.setPayCosts(new Cost(costs, true));
|
||||
emptyAbility.setTargetRestrictions(sa.getTargetRestrictions());
|
||||
|
||||
emptyAbility.setActivatingPlayer(ai);
|
||||
if (!ComputerUtilCost.canPayCost(emptyAbility, ai)) {
|
||||
// AiPlayDecision.AnotherTime
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user