MayFlashSac: rework using MayPlayNotSorcerySpeed

This commit is contained in:
Hanmac
2018-05-06 08:55:10 +02:00
parent 4cf79222f0
commit 198e7adc47
5 changed files with 27 additions and 22 deletions

View File

@@ -35,7 +35,7 @@ public class PermanentAi extends SpellAbilityAi {
final Card card = sa.getHostCard(); final Card card = sa.getHostCard();
if (card.hasStartOfKeyword("You may cast CARDNAME as though it had flash. If") && !ai.couldCastSorcery(sa)) { if (card.hasKeyword("MayFlashSac") && !ai.couldCastSorcery(sa)) {
// AiPlayDecision.AnotherTime // AiPlayDecision.AnotherTime
return false; return false;
} }

View File

@@ -147,6 +147,10 @@ public final class GameActionUtil {
} }
for (CardPlayOption o : source.mayPlay(activator)) { for (CardPlayOption o : source.mayPlay(activator)) {
// do not appear if it can be cast with SorcerySpeed
if (o.getAbility().hasParam("MayPlayNotSorcerySpeed") && activator.couldCastSorcery(sa)) {
continue;
}
// non basic are only allowed if PayManaCost is yes // non basic are only allowed if PayManaCost is yes
if (!sa.isBasicSpell() && o.getPayManaCost() == PayManaCost.NO) { if (!sa.isBasicSpell() && o.getPayManaCost() == PayManaCost.NO) {
continue; continue;
@@ -418,6 +422,19 @@ public final class GameActionUtil {
i++; i++;
} }
} }
} else if (keyword.startsWith("MayFlashCost")) {
final String[] k = keyword.split(":");
for (int i = 0; i < abilities.size(); i++) {
final SpellAbility newSA = abilities.get(i).copy();
newSA.setBasicSpell(false);
newSA.setPayCosts(new Cost(k[1], false).add(newSA.getPayCosts()));
newSA.setDescription(newSA.getDescription() + " (as though it had flash)");
newSA.getRestrictions().setInstantSpeed(true);
if (newSA.canPlay()) {
abilities.add(i, newSA);
i++;
}
}
} else if (keyword.startsWith("Kicker")) { } else if (keyword.startsWith("Kicker")) {
String[] sCosts = TextUtil.split(keyword.substring(6), ':'); String[] sCosts = TextUtil.split(keyword.substring(6), ':');
boolean generic = "Generic".equals(sCosts[sCosts.length - 1]); boolean generic = "Generic".equals(sCosts[sCosts.length - 1]);

View File

@@ -3032,7 +3032,7 @@ public class CardFactoryUtil {
inst.addTrigger(parsedUpkeepTrig); inst.addTrigger(parsedUpkeepTrig);
inst.addTrigger(parsedSacTrigger); inst.addTrigger(parsedSacTrigger);
} else if (keyword.equals("MayFlashSac")) { } else if (keyword.equals("MayFlashSac")) {
String strTrig = "Mode$ SpellCast | ValidCard$ Card.Self | Static$ True | Secondary$ True | SpellSpeed$ NotSorcerySpeed" String strTrig = "Mode$ SpellCast | ValidCard$ Card.Self | ValidSA$ Spell.MayPlaySource | Static$ True | Secondary$ True "
+ " | TriggerDescription$ If you cast it any time a sorcery couldn't have been cast, " + " | TriggerDescription$ If you cast it any time a sorcery couldn't have been cast, "
+ " the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step."; + " the controller of the permanent it becomes sacrifices it at the beginning of the next cleanup step.";
@@ -4286,8 +4286,8 @@ public class CardFactoryUtil {
effect = "Mode$ CantBlockBy | ValidAttacker$ Creature.Self | ValidBlocker$ " + k[1] effect = "Mode$ CantBlockBy | ValidAttacker$ Creature.Self | ValidBlocker$ " + k[1]
+ " | Description$ CARDNAME can't be blocked " + getTextForKwCantBeBlockedByType(keyword); + " | Description$ CARDNAME can't be blocked " + getTextForKwCantBeBlockedByType(keyword);
} else if (keyword.equals("MayFlashSac")) { } else if (keyword.equals("MayFlashSac")) {
effect = "Mode$ Continuous | EffectZone$ All | Affected$ Card.Self | Secondary$ True" effect = "Mode$ Continuous | EffectZone$ All | Affected$ Card.Self | Secondary$ True | MayPlay$ True"
+ " | MayPlay$ True | MayPlayWithFlash$ True | MayPlayText$ Sacrifice at the next cleanup step" + " | MayPlayNotSorcerySpeed$ True | MayPlayWithFlash$ True | MayPlayText$ Sacrifice at the next cleanup step"
+ " | AffectedZone$ Exile,Graveyard,Hand,Library,Stack | Description$ " + inst.getReminderText(); + " | AffectedZone$ Exile,Graveyard,Hand,Library,Stack | Description$ " + inst.getReminderText();
} }

View File

@@ -127,9 +127,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
game.getAction().checkStaticAbilities(false); game.getAction().checkStaticAbilities(false);
} }
if (!(isInstant || activator.canCastSorcery() || flash if (!(isInstant || activator.canCastSorcery() || flash || getRestrictions().isInstantSpeed()
|| getRestrictions().isInstantSpeed()
|| card.hasStartOfKeyword("You may cast CARDNAME as though it had flash.")
|| this.hasSVar("IsCastFromPlayEffect") || this.hasSVar("IsCastFromPlayEffect")
|| (card.isFaceDown() && !card.getLastKnownZone().is(ZoneType.Battlefield) && card.getState(CardStateName.Original).getType().isInstant()))) { || (card.isFaceDown() && !card.getLastKnownZone().is(ZoneType.Battlefield) && card.getState(CardStateName.Original).getType().isInstant()))) {
return false; return false;

View File

@@ -124,6 +124,11 @@ public class TriggerSpellAbilityCast extends Trigger {
return false; return false;
} }
} }
if (hasParam("ValidSA")) {
if (!matchesValid(spellAbility, getParam("ValidSA").split(","), getHostCard())) {
return false;
}
}
if (hasParam("TargetsValid")) { if (hasParam("TargetsValid")) {
SpellAbility sa = spellAbility; SpellAbility sa = spellAbility;
@@ -205,21 +210,6 @@ public class TriggerSpellAbilityCast extends Trigger {
} }
} }
if (hasParam("SpellSpeed")) {
if (getParam("SpellSpeed").equals("NotSorcerySpeed")) {
if (getHostCard().getController().couldCastSorcery(spellAbility)) {
return false;
}
// TODO do we need check if it could have been cast with normal Flash?
StaticAbility sta = spellAbility.getMayPlay();
if (sta == null || !getHostCard().equals(sta.getHostCard())) {
return false;
}
}
}
if (hasParam("SharesNameWithActivatorsZone")) { if (hasParam("SharesNameWithActivatorsZone")) {
String zones = getParam("SharesNameWithActivatorsZone"); String zones = getParam("SharesNameWithActivatorsZone");
if (si == null) { if (si == null) {