Merge branch 'cardfixes' into 'master'

Entwine fix

See merge request core-developers/forge!4941
This commit is contained in:
Michael Kamensky
2021-07-03 13:27:06 +00:00
4 changed files with 20 additions and 18 deletions

View File

@@ -23,21 +23,23 @@ import forge.util.collect.FCollection;
public class CharmAi extends SpellAbilityAi { public class CharmAi extends SpellAbilityAi {
@Override @Override
protected boolean checkApiLogic(Player ai, SpellAbility sa) { protected boolean checkApiLogic(Player ai, SpellAbility sa) {
// sa is Entwined, no need for extra logic
if (sa.isEntwine()) {
return true;
}
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
final int num = AbilityUtils.calculateAmount(source, sa.getParamOrDefault("CharmNum", "1"), sa); final int num;
final int min = sa.hasParam("MinCharmNum") ? AbilityUtils.calculateAmount(source, sa.getParamOrDefault("MinCharmNum", "1"), sa) : num; final int min;
if (sa.isEntwine()) {
num = min = choices.size();
}
else {
num = AbilityUtils.calculateAmount(source, sa.getParamOrDefault("CharmNum", "1"), sa);
min = sa.hasParam("MinCharmNum") ? AbilityUtils.calculateAmount(source, sa.getParamOrDefault("MinCharmNum", "1"), sa) : num;
}
boolean timingRight = sa.isTrigger(); //is there a reason to play the charm now? boolean timingRight = sa.isTrigger(); //is there a reason to play the charm now?
// Reset the chosen list otherwise it will be locked in forever by earlier calls // Reset the chosen list otherwise it will be locked in forever by earlier calls
sa.setChosenList(null); sa.setChosenList(null);
List<AbilitySub> choices = CharmEffect.makePossibleOptions(sa);
List<AbilitySub> chosenList; List<AbilitySub> chosenList;
if (!ai.equals(sa.getActivatingPlayer())) { if (!ai.equals(sa.getActivatingPlayer())) {
@@ -159,7 +161,7 @@ public class CharmAi extends SpellAbilityAi {
chosenList.add(allyTainted ? gain : lose); chosenList.add(allyTainted ? gain : lose);
} else if (oppTainted || ai.getGame().isCardInPlay("Rain of Gore")) { } else if (oppTainted || ai.getGame().isCardInPlay("Rain of Gore")) {
// Rain of Gore does negate lifegain, so don't benefit the others // Rain of Gore does negate lifegain, so don't benefit the others
// same for if a oppoent does control Tainted Remedy // same for if a opponent does control Tainted Remedy
// but if ai cant gain life, the effects are negated // but if ai cant gain life, the effects are negated
chosenList.add(ai.canGainLife() ? lose : gain); chosenList.add(ai.canGainLife() ? lose : gain);
} else if (ai.getGame().isCardInPlay("Sulfuric Vortex")) { } else if (ai.getGame().isCardInPlay("Sulfuric Vortex")) {
@@ -177,13 +179,13 @@ public class CharmAi extends SpellAbilityAi {
chosenList.add(gain); chosenList.add(gain);
} else if(!ai.canGainLife() && aiLife == 14 ) { } else if(!ai.canGainLife() && aiLife == 14 ) {
// ai cant gain life, but try to avoid falling to 13 // ai cant gain life, but try to avoid falling to 13
// but if a oppoent does control Tainted Remedy its irrelevant // but if a opponent does control Tainted Remedy its irrelevant
chosenList.add(oppTainted ? lose : gain); chosenList.add(oppTainted ? lose : gain);
} else if (allyTainted) { } else if (allyTainted) {
// Tainted Remedy negation logic, try gain instead of lose // Tainted Remedy negation logic, try gain instead of lose
// because negation does turn it into lose for opponents // because negation does turn it into lose for opponents
boolean oppCritical = false; boolean oppCritical = false;
// an oppoent is Critical = 14, and can't gain life, try to lose life instead // an opponent is Critical = 14, and can't gain life, try to lose life instead
// but only if ai doesn't kill itself with that. // but only if ai doesn't kill itself with that.
if (aiLife != 14) { if (aiLife != 14) {
for (Player p : opponents) { for (Player p : opponents) {
@@ -197,7 +199,7 @@ public class CharmAi extends SpellAbilityAi {
} else { } else {
// normal logic, try to gain life if its critical // normal logic, try to gain life if its critical
boolean oppCritical = false; boolean oppCritical = false;
// an oppoent is Critical = 12, and can gain life, try to gain life instead // an opponent is Critical = 12, and can gain life, try to gain life instead
// but only if ai doesn't kill itself with that. // but only if ai doesn't kill itself with that.
if (aiLife != 12) { if (aiLife != 12) {
for (Player p : opponents) { for (Player p : opponents) {
@@ -224,6 +226,8 @@ public class CharmAi extends SpellAbilityAi {
goodChoice = sub; goodChoice = sub;
} else { } else {
// Standard canPlayAi() // Standard canPlayAi()
sub.setActivatingPlayer(ai);
sub.getRestrictions().setZone(sub.getParent().getRestrictions().getZone());
if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) { if (AiPlayDecision.WillPlay == aic.canPlaySa(sub)) {
chosenList.add(sub); chosenList.add(sub);
if (chosenList.size() == min) { if (chosenList.size() == min) {

View File

@@ -175,7 +175,6 @@ public class PermanentCreatureAi extends PermanentAi {
} }
} }
if (hasFloatMana || willDiscardNow || willDieNow) { if (hasFloatMana || willDiscardNow || willDieNow) {
// Will lose mana in pool or about to discard a card in cleanup or about to die in combat, so use this opportunity // Will lose mana in pool or about to discard a card in cleanup or about to die in combat, so use this opportunity
return true; return true;
@@ -206,7 +205,6 @@ public class PermanentCreatureAi extends PermanentAi {
@Override @Override
protected boolean checkApiLogic(Player ai, SpellAbility sa) { protected boolean checkApiLogic(Player ai, SpellAbility sa) {
if (!super.checkApiLogic(ai, sa)) { if (!super.checkApiLogic(ai, sa)) {
return false; return false;
} }

View File

@@ -121,7 +121,7 @@ public class CostAdjustment {
String amount = st.getParam("Amount"); String amount = st.getParam("Amount");
if ("Escalate".equals(amount)) { if ("Escalate".equals(amount)) {
SpellAbility sub = sa; SpellAbility sub = sa;
while(sub != null) { while (sub != null) {
if (sub.getDirectSVars().containsKey("CharmOrder")) { if (sub.getDirectSVars().containsKey("CharmOrder")) {
count++; count++;
} }
@@ -148,7 +148,7 @@ public class CostAdjustment {
// Amount 1 as default // Amount 1 as default
count = 1; count = 1;
} }
for(int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
cost.add(part); cost.add(part);
} }
} }

View File

@@ -3,7 +3,7 @@ ManaCost:W B G
Types:Legendary Creature Elf Advisor Types:Legendary Creature Elf Advisor
PT:3/4 PT:3/4
S:Mode$ ReduceCost | ValidCard$ Legendary | Type$ Spell | Activator$ You | Amount$ 1 | Description$ Legendary spells you cast cost {1} less to cast. S:Mode$ ReduceCost | ValidCard$ Legendary | Type$ Spell | Activator$ You | Amount$ 1 | Description$ Legendary spells you cast cost {1} less to cast.
A:AB$ Animate | Cost$ ExileFromGrave<2/Card.Legendary/legendary card> | staticAbilities$ Play | Defined$ ValidGraveyard Card.Legendary+YouOwn | SpellDescription$ Until end of turn, each legendary card in your graveyard gains "You may play this card from your graveyard." A:AB$ Effect | Cost$ ExileFromGrave<2/Card.Legendary/legendary card> | StaticAbilities$ Play | SpellDescription$ Until end of turn, each legendary card in your graveyard gains "You may play this card from your graveyard."
SVar:Play:Mode$ Continuous | Affected$ Card.Self | EffectZone$ Graveyard | MayPlay$ True | Description$ You may play this card from your graveyard. SVar:Play:Mode$ Continuous | Affected$ Card.Legendary+YouOwn | AffectedZone$ Graveyard | MayPlay$ True | Description$ Until end of turn, each legendary card in your graveyard gains "You may play this card from your graveyard."
DeckHints:Type$Legendary DeckHints:Type$Legendary
Oracle:Legendary spells you cast cost {1} less to cast.\nExile two legendary cards from your graveyard: Until end of turn, each legendary card in your graveyard gains "You may play this card from your graveyard." Oracle:Legendary spells you cast cost {1} less to cast.\nExile two legendary cards from your graveyard: Until end of turn, each legendary card in your graveyard gains "You may play this card from your graveyard."