Logic for Tyvar the Bellicose (#3620)

* Fix Rocco

* Tyvar logic

---------

Co-authored-by: TRT <>
This commit is contained in:
tool4ever
2023-08-11 21:14:16 +02:00
committed by GitHub
parent a4011d8500
commit a2f7f512ee
3 changed files with 21 additions and 15 deletions

View File

@@ -338,13 +338,11 @@ public class ChangeZoneAi extends SpellAbilityAi {
}
String type = sa.getParam("ChangeType");
if (type != null) {
if (type.contains("X") && sa.getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value.
final int xPay = ComputerUtilCost.getMaxXValue(sa, ai, sa.isTrigger());
sa.setXManaCostPaid(xPay);
type = type.replace("X", Integer.toString(xPay));
}
if (type != null && type.contains("X") && sa.getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value.
final int xPay = ComputerUtilCost.getMaxXValue(sa, ai, sa.isTrigger());
sa.setXManaCostPaid(xPay);
type = type.replace("X", Integer.toString(xPay));
}
for (final Player p : pDefined) {
@@ -500,7 +498,7 @@ public class ChangeZoneAi extends SpellAbilityAi {
// this works for hidden because the mana is paid first.
final String type = sa.getParam("ChangeType");
if (type != null && type.contains("X") && sa.getSVar("X").equals("Count$xPaid")) {
if (!mandatory && sa.getPayCosts().hasXInAnyCostPart() && type != null && type.contains("X") && sa.getSVar("X").equals("Count$xPaid")) {
// Set PayX here to maximum value.
final int xPay = ComputerUtilCost.getMaxXValue(sa, ai, sa.isTrigger());
sa.setXManaCostPaid(xPay);

View File

@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.List;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import forge.ai.AiPlayDecision;
import forge.ai.ComputerUtil;
@@ -17,6 +18,7 @@ import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.card.mana.ManaAtom;
import forge.card.mana.ManaCost;
import forge.game.CardTraitPredicates;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card;
import forge.game.card.CardCollection;
@@ -65,7 +67,7 @@ public class ManaEffectAi extends SpellAbilityAi {
*/
@Override
protected boolean checkPhaseRestrictions(Player ai, SpellAbility sa, PhaseHandler ph) {
if (ph.is(PhaseType.END_OF_TURN) && (ph.getNextTurn() == ai || ComputerUtilCard.willUntap(ai, sa.getHostCard())) && canRampPool(ai, sa.getHostCard())) {
if (improvesPosition(ai, sa)) {
return true;
}
if (!ph.is(PhaseType.MAIN2)) {
@@ -109,12 +111,8 @@ public class ManaEffectAi extends SpellAbilityAi {
return true;
}
PhaseHandler ph = ai.getGame().getPhaseHandler();
boolean moreManaNextTurn = ph.is(PhaseType.END_OF_TURN) && (ph.getNextTurn() == ai || ComputerUtilCard.willUntap(ai, sa.getHostCard()))
&& canRampPool(ai, sa.getHostCard());
return sa.getPayCosts().hasNoManaCost() && sa.getPayCosts().isReusuableResource()
&& sa.getSubAbility() == null && (moreManaNextTurn || ComputerUtil.playImmediately(ai, sa));
&& sa.getSubAbility() == null && (improvesPosition(ai, sa) || ComputerUtil.playImmediately(ai, sa));
}
/**
@@ -262,6 +260,16 @@ public class ManaEffectAi extends SpellAbilityAi {
return castableSpells.size() > 0;
}
private boolean improvesPosition(Player ai, SpellAbility sa) {
boolean activateForTrigger = Iterables.any(Iterables.filter(sa.getHostCard().getTriggers(), CardTraitPredicates.hasParam("AILogic", "ActivateOnce")),
t -> sa.getHostCard().getAbilityActivatedThisTurn(t.getOverridingAbility()) == 0);
PhaseHandler ph = ai.getGame().getPhaseHandler();
// TODO if threatened use right away
return ph.is(PhaseType.END_OF_TURN) && (ph.getNextTurn() == ai || ComputerUtilCard.willUntap(ai, sa.getHostCard()))
&& (activateForTrigger || canRampPool(ai, sa.getHostCard()));
}
public static boolean canRampPool(Player ai, Card source) {
ManaPool mp = ai.getManaPool();
Mana test = null;

View File

@@ -5,7 +5,7 @@ PT:5/4
T:Mode$ AttackersDeclared | ValidAttackers$ Elf.YouCtrl | Execute$ TrigPump | TriggerZones$ Battlefield | TriggerDescription$ Whenever one or more Elves you control attack, they gain deathtouch until end of turn.
SVar:TrigPump:DB$ Pump | Defined$ TriggeredAttackers | KW$ Deathtouch
S:Mode$ Continuous | Affected$ Creature.YouCtrl | AddTrigger$ ManaTrig | Description$ Each creature you control has "Whenever a mana ability of this creature resolves, put a number of +1/+1 counters on it equal to the amount of mana this creature produced. This ability triggers only once each turn."
SVar:ManaTrig:Mode$ AbilityResolves | ValidSource$ Card.Self | ValidSpellAbility$ SpellAbility.ManaAbility | ActivationLimit$ 1 | TriggerZones$ Battlefield | Execute$ TrigPutCounter | TriggerDescription$ Whenever a mana ability of this creature resolves, put a number of +1/+1 counters on it equal to the amount of mana this creature produced. This ability triggers only once each turn.
SVar:ManaTrig:Mode$ AbilityResolves | ValidSource$ Card.Self | ValidSpellAbility$ SpellAbility.ManaAbility | ActivationLimit$ 1 | TriggerZones$ Battlefield | Execute$ TrigPutCounter | AILogic$ ActivateOnce | TriggerDescription$ Whenever a mana ability of this creature resolves, put a number of +1/+1 counters on it equal to the amount of mana this creature produced. This ability triggers only once each turn.
SVar:TrigPutCounter:DB$ PutCounter | CounterType$ P1P1 | CounterNum$ X
SVar:X:TriggeredSpellAbility$AmountManaProduced
DeckHints:Type$Elf