- A hacky workaround for the interaction between As Foretold and split cards. Seems to work in general cases, for both non-Aftermath and Aftermath splits, but a better solution is most certainly needed and welcome.

This commit is contained in:
Agetian
2017-09-10 16:25:32 +00:00
parent 94693f530e
commit 6a262ea604
5 changed files with 55 additions and 7 deletions

View File

@@ -27,10 +27,7 @@ import forge.game.ability.AbilityFactory;
import forge.game.ability.AbilityFactory.AbilityRecordType;
import forge.game.ability.AbilityUtils;
import forge.game.ability.ApiType;
import forge.game.card.Card;
import forge.game.card.CardCollectionView;
import forge.game.card.CardPlayOption;
import forge.game.card.CardPredicates;
import forge.game.card.*;
import forge.game.card.CardPlayOption.PayManaCost;
import forge.game.cost.Cost;
import forge.game.mana.ManaCostBeingPaid;
@@ -151,6 +148,20 @@ public final class GameActionUtil {
newSA.setBasicSpell(false);
newSA.setPayCosts(newSA.getPayCosts().copyWithDefinedMana(o.getAltManaCost()));
changedManaCost = true;
if (host.hasSVar("AsForetoldSplitCMCHack")) {
// FIXME: A temporary workaround for As Foretold interaction with split cards, better solution needed.
if (sa.isLeftSplit()) {
int leftCMC = sa.getHostCard().getCMC(Card.SplitCMCMode.LeftSplitCMC);
if (leftCMC > host.getCounters(CounterType.TIME)) {
continue;
}
} else if (sa.isRightSplit()) {
int rightCMC = sa.getHostCard().getCMC(Card.SplitCMCMode.RightSplitCMC);
if (rightCMC > host.getCounters(CounterType.TIME)) {
continue;
}
}
}
}
if (changedManaCost) {
if ("0".equals(sa.getParam("ActivationLimit")) && sa.getHostCard().getManaCost().isNoCost()) {

View File

@@ -3,6 +3,7 @@ package forge.game.card;
import java.util.Collections;
import java.util.List;
import forge.card.CardStateName;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterables;
@@ -95,6 +96,36 @@ public class CardProperty {
if (!card.isFlipCard()) {
return false;
}
} else if (property.equals("Split")) {
if (!card.isSplitCard()) {
return false;
}
} else if (property.equals("NotSplit")) {
if (card.isSplitCard()) {
return false;
}
} else if (property.startsWith("leftcmc") || property.startsWith("rightcmc")) {
int x;
int y = 0;
String rhs = "";
if (property.startsWith("leftcmc")) {
rhs = property.substring(9);
y = card.getState(CardStateName.LeftSplit).getManaCost().getCMC();
} else if (property.startsWith("rightcmc")) {
rhs = property.substring(10);
y = card.getState(CardStateName.RightSplit).getManaCost().getCMC();
}
try {
x = Integer.parseInt(rhs);
} catch (final NumberFormatException e) {
x = AbilityUtils.calculateAmount(source, rhs, spellAbility);
}
if (!Expressions.compare(y, property, x)) {
return false;
}
} else if (property.startsWith("YouCtrl")) {
if (!controller.equals(sourceController)) {
return false;

View File

@@ -252,6 +252,10 @@ public class SpellAbilityRestriction extends SpellAbilityVariables {
break;
}
}
if (cardZone.is(ZoneType.Graveyard) && sa.isAftermath()) {
// Special exclusion for Aftermath, useful for e.g. As Foretold
return true;
}
if (!hasOtherGrantor) {
return false;
}