mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
- Basic logic for fake counter move on Spikes from Tempest.
This commit is contained in:
@@ -11,6 +11,7 @@ import forge.game.GameEntity;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.*;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.cost.*;
|
||||
import forge.game.keyword.Keyword;
|
||||
@@ -43,6 +44,8 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
protected boolean willPayCosts(Player ai, SpellAbility sa, Cost cost, Card source) {
|
||||
|
||||
final String type = sa.getParam("CounterType");
|
||||
final String aiLogic = sa.getParamOrDefault("AILogic", "");
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
if (!super.willPayCosts(ai, sa, cost, source)) {
|
||||
return false;
|
||||
@@ -53,7 +56,7 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (part instanceof CostRemoveCounter) {
|
||||
final CostRemoveCounter remCounter = (CostRemoveCounter) part;
|
||||
final CounterType counterType = remCounter.counter;
|
||||
if (counterType.name().equals(type)) {
|
||||
if (counterType.name().equals(type) && !aiLogic.startsWith("MoveCounter")) {
|
||||
return false;
|
||||
}
|
||||
if (!part.payCostFromSource()) {
|
||||
@@ -279,6 +282,36 @@ public class CountersPutAi extends SpellAbilityAi {
|
||||
if (!source.canTransform()) {
|
||||
return false;
|
||||
}
|
||||
} else if (logic.equals("MoveCounterSpike")) {
|
||||
// Spikes (Tempest)
|
||||
|
||||
// Try not to do it unless at the end of opponent's turn or the creature is threatened
|
||||
Combat combat = ai.getGame().getCombat();
|
||||
boolean threatened = ComputerUtil.predictThreatenedObjects(ai, null, true).contains(sa.getHostCard());
|
||||
|
||||
if (!(threatened || (ph.is(PhaseType.END_OF_TURN) && ph.getNextTurn() == ai))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CardCollection targets = CardLists.getTargetableCards(ai.getCreaturesInPlay(), sa);
|
||||
targets.remove(sa.getHostCard());
|
||||
|
||||
targets = CardLists.filter(targets, new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card card) {
|
||||
// when threatened, any target is good to preserve the counter
|
||||
return threatened || ComputerUtilCard.evaluateCreature(card, false, false) > ComputerUtilCard.evaluateCreature(sa.getHostCard(), false, false);
|
||||
}
|
||||
});
|
||||
|
||||
Card bestTgt = ComputerUtilCard.getBestCreatureAI(targets);
|
||||
|
||||
if (bestTgt != null) {
|
||||
sa.getTargets().add(bestTgt);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sa.getConditions() != null && !sa.getConditions().areMet(sa) && sa.getSubAbility() == null) {
|
||||
|
||||
Reference in New Issue
Block a user