mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Added a way to define card-based AI priority for paying the Remove Counter cost.
- Set the AI priority for Power Conduit to ANY to avoid the AI lagging heavily while looping through the cost and spamming the console with errors. - Currently the AI will use this card rather randomly. Consider improving or marking it as RemRandomDeck at the very least.
This commit is contained in:
@@ -22,6 +22,7 @@ import forge.game.player.Player;
|
|||||||
import forge.game.spellability.SpellAbility;
|
import forge.game.spellability.SpellAbility;
|
||||||
import forge.game.spellability.SpellAbilityStackInstance;
|
import forge.game.spellability.SpellAbilityStackInstance;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.collect.FCollectionView;
|
import forge.util.collect.FCollectionView;
|
||||||
|
|
||||||
public class AiCostDecision extends CostDecisionMakerBase {
|
public class AiCostDecision extends CostDecisionMakerBase {
|
||||||
@@ -710,6 +711,36 @@ public class AiCostDecision extends CostDecisionMakerBase {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if the card defines its own priorities for counter removal as cost
|
||||||
|
if (source.hasSVar("AIRemoveCounterCostPriority")) {
|
||||||
|
String[] counters = TextUtil.split(source.getSVar("AIRemoveCounterCostPriority"), ',');
|
||||||
|
|
||||||
|
for (final String ctr : counters) {
|
||||||
|
List<Card> withCtr = CardLists.filter(typeList, new Predicate<Card>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(final Card crd) {
|
||||||
|
for (Map.Entry<CounterType, Integer> e : crd.getCounters().entrySet()) {
|
||||||
|
if (e.getValue() >= c && (ctr.equals("ANY") || e.getKey() == CounterType.valueOf(ctr))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!withCtr.isEmpty()) {
|
||||||
|
final Card card = withCtr.get(0);
|
||||||
|
PaymentDecision result = PaymentDecision.card(card);
|
||||||
|
|
||||||
|
for (Map.Entry<CounterType, Integer> e : card.getCounters().entrySet()) {
|
||||||
|
if (e.getValue() >= c && (ctr.equals("ANY") || e.getKey() == CounterType.valueOf(ctr))) {
|
||||||
|
result.ct = e.getKey();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ Types:Artifact
|
|||||||
A:AB$ Charm | Cost$ T RemoveAnyCounter<1/Permanent.YouCtrl/a permanent you control> | Choices$ ConduitCharge,ConduitP1P1 | Defined$ You
|
A:AB$ Charm | Cost$ T RemoveAnyCounter<1/Permanent.YouCtrl/a permanent you control> | Choices$ ConduitCharge,ConduitP1P1 | Defined$ You
|
||||||
SVar:ConduitCharge:DB$ PutCounter | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | CounterType$ CHARGE | CounterNum$ 1 | SpellDescription$ Put a charge counter on target artifact.
|
SVar:ConduitCharge:DB$ PutCounter | ValidTgts$ Artifact | TgtPrompt$ Select target artifact | CounterType$ CHARGE | CounterNum$ 1 | SpellDescription$ Put a charge counter on target artifact.
|
||||||
SVar:ConduitP1P1:DB$ PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ 1 | SpellDescription$ Put a +1/+1 counter on target creature.
|
SVar:ConduitP1P1:DB$ PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ 1 | SpellDescription$ Put a +1/+1 counter on target creature.
|
||||||
|
SVar:AIRemoveCounterCostPriority:ANY
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/power_conduit.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/power_conduit.jpg
|
||||||
Oracle:{T}, Remove a counter from a permanent you control: Choose one —\n• Put a charge counter on target artifact.\n• Put a +1/+1 counter on target creature.
|
Oracle:{T}, Remove a counter from a permanent you control: Choose one —\n• Put a charge counter on target artifact.\n• Put a +1/+1 counter on target creature.
|
||||||
|
|||||||
Reference in New Issue
Block a user