Fix AI for Ludevic

This commit is contained in:
tool4EvEr
2021-09-24 21:55:01 +02:00
parent d0abc02bc5
commit c88d5b373a
4 changed files with 21 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ package forge.ai.ability;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCard;
import forge.ai.ComputerUtilCost;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.card.CardStateName; import forge.card.CardStateName;
import forge.game.Game; import forge.game.Game;
@@ -30,7 +31,7 @@ public class SetStateAi extends SpellAbilityAi {
final String mode = sa.getParam("Mode"); final String mode = sa.getParam("Mode");
// turning face is most likely okay // turning face is most likely okay
if("TurnFace".equals(mode)) { if ("TurnFace".equals(mode)) {
return true; return true;
} }
@@ -39,7 +40,12 @@ public class SetStateAi extends SpellAbilityAi {
return false; return false;
} }
if("Transform".equals(mode) || "Flip".equals(mode)) { if (sa.getSVar("X").equals("Count$xPaid")) {
final int xPay = ComputerUtilCost.getMaxXValue(sa, aiPlayer);
sa.setXManaCostPaid(xPay);
}
if ("Transform".equals(mode) || "Flip".equals(mode)) {
return true; return true;
} }
return false; return false;
@@ -146,7 +152,6 @@ public class SetStateAi extends SpellAbilityAi {
// TODO: compareCards assumes that a creature will transform into a creature. Need to improve this // TODO: compareCards assumes that a creature will transform into a creature. Need to improve this
// for other things potentially transforming. // for other things potentially transforming.
return compareCards(card, transformed, ai, ph); return compareCards(card, transformed, ai, ph);
} }
private boolean shouldTurnFace(Card card, Player ai, PhaseHandler ph) { private boolean shouldTurnFace(Card card, Player ai, PhaseHandler ph) {

View File

@@ -18,6 +18,7 @@
package forge.game.cost; package forge.game.cost;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.card.CardCollectionView; import forge.game.card.CardCollectionView;
import forge.game.card.CardLists; import forge.game.card.CardLists;
@@ -131,8 +132,7 @@ public class CostExile extends CostPartWithList {
CardCollectionView list; CardCollectionView list;
if (this.sameZone) { if (this.sameZone) {
list = game.getCardsIn(this.from); list = game.getCardsIn(this.from);
} } else {
else {
list = payer.getCardsIn(this.from); list = payer.getCardsIn(this.from);
} }
@@ -146,6 +146,10 @@ public class CostExile extends CostPartWithList {
Integer amount = this.convertAmount(); Integer amount = this.convertAmount();
if (amount == null) { // try to calculate when it's defined.
amount = AbilityUtils.calculateAmount(ability.getHostCard(), getAmount(), ability);
}
// for cards like Allosaurus Rider, do not count it // for cards like Allosaurus Rider, do not count it
if (this.from == ZoneType.Hand && source.isInZone(ZoneType.Hand) && list.contains(source)) { if (this.from == ZoneType.Hand && source.isInZone(ZoneType.Hand) && list.contains(source)) {
amount++; amount++;

View File

@@ -64,12 +64,10 @@ public class CostGainLife extends CostPart {
return sb.toString(); return sb.toString();
} }
public List<Player> getPotentialTargets(final Player payer, final Card source) public List<Player> getPotentialTargets(final Player payer, final Card source) {
{
List<Player> res = new ArrayList<>(); List<Player> res = new ArrayList<>();
for(Player p : payer.getGame().getPlayers()) for (Player p : payer.getGame().getPlayers()) {
{ if (p.isValid(getType(), payer, source, null))
if(p.isValid(getType(), payer, source, null))
res.add(p); res.add(p);
} }
return res; return res;
@@ -85,7 +83,7 @@ public class CostGainLife extends CostPart {
@Override @Override
public final boolean canPay(final SpellAbility ability, final Player payer) { public final boolean canPay(final SpellAbility ability, final Player payer) {
final Integer amount = this.convertAmount(); final Integer amount = this.convertAmount();
if ( amount == null ) return false; if (amount == null) return false;
int cntAbleToGainLife = 0; int cntAbleToGainLife = 0;
List<Player> possibleTargets = getPotentialTargets(payer, ability.getHostCard()); List<Player> possibleTargets = getPotentialTargets(payer, ability.getHostCard());

View File

@@ -3,8 +3,9 @@ ManaCost:X G
Types:Creature Human Types:Creature Human
PT:0/0 PT:0/0
K:etbCounter:P1P1:X K:etbCounter:P1P1:X
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | CheckSVar$ X | SVarCompare$ GE3 | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Coven — At the beginning of your end step, if you control three or more creatures with different powers, put a +1/+1 counter on target creature you control. T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | CheckSVar$ Y | SVarCompare$ GE3 | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Coven — At the beginning of your end step, if you control three or more creatures with different powers, put a +1/+1 counter on target creature you control.
SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | CounterType$ P1P1 | CounterNum$ 1 SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | CounterType$ P1P1 | CounterNum$ 1
SVar:X:Count$DifferentPower_Creature.YouCtrl SVar:X:Count$xPaid
SVar:Y:Count$DifferentPower_Creature.YouCtrl
DeckHas:Ability$Counters DeckHas:Ability$Counters
Oracle:Contortionist Troupe enters the battlefield with X +1/+1 counters on it.\nCoven — At the beginning of your end step, if you control three or more creatures with different powers, put a +1/+1 counter on target creature you control. Oracle:Contortionist Troupe enters the battlefield with X +1/+1 counters on it.\nCoven — At the beginning of your end step, if you control three or more creatures with different powers, put a +1/+1 counter on target creature you control.