CardPlayOption: add MayPlayWithFlash

This commit is contained in:
Hanmac
2016-07-28 07:06:58 +00:00
parent eb2b531c9d
commit a5728b9761
4 changed files with 27 additions and 24 deletions

View File

@@ -192,11 +192,14 @@ public final class GameActionUtil {
final SpellAbility newSA = sa.copy(); final SpellAbility newSA = sa.copy();
final SpellAbilityRestriction sar = new SpellAbilityRestriction(); final SpellAbilityRestriction sar = new SpellAbilityRestriction();
sar.setVariables(sa.getRestrictions()); sar.setVariables(sa.getRestrictions());
if (playOption.isWithFlash()) {
sar.setInstantSpeed(true);
}
sar.setZone(null); sar.setZone(null);
newSA.setRestrictions(sar); newSA.setRestrictions(sar);
newSA.setBasicSpell(false); newSA.setBasicSpell(false);
newSA.setPayCosts(newSA.getPayCosts().copyWithNoMana()); newSA.setPayCosts(newSA.getPayCosts().copyWithNoMana());
newSA.setDescription(sa.getDescription() + " (without paying its mana cost)"); newSA.setDescription(sa.getDescription() + playOption.toString());
alternatives.add(newSA); alternatives.add(newSA);
} }
} }
@@ -227,17 +230,6 @@ public final class GameActionUtil {
newSA.setDescription(sa.getDescription() + " (without paying its mana cost)"); newSA.setDescription(sa.getDescription() + " (without paying its mana cost)");
alternatives.add(newSA); alternatives.add(newSA);
} }
if (sa.isSpell() && keyword.startsWith("May be played without paying its mana cost and as though it has flash")) {
final SpellAbility newSA = sa.copy();
SpellAbilityRestriction sar = new SpellAbilityRestriction();
sar.setVariables(sa.getRestrictions());
sar.setInstantSpeed(true);
newSA.setRestrictions(sar);
newSA.setBasicSpell(false);
newSA.setPayCosts(newSA.getPayCosts().copyWithNoMana());
newSA.setDescription(sa.getDescription() + " (without paying its mana cost and as though it has flash)");
alternatives.add(newSA);
}
if (sa.isSpell() && keyword.startsWith("Alternative Cost")) { if (sa.isSpell() && keyword.startsWith("Alternative Cost")) {
final SpellAbility newSA = sa.copy(); final SpellAbility newSA = sa.copy();
newSA.setBasicSpell(false); newSA.setBasicSpell(false);

View File

@@ -2277,9 +2277,9 @@ public class Card extends GameEntity implements Comparable<Card> {
public final CardPlayOption mayPlay(final Player player) { public final CardPlayOption mayPlay(final Player player) {
return mayPlay.get(player); return mayPlay.get(player);
} }
public final void setMayPlay(final Player player, final boolean withoutManaCost, final boolean ignoreColor) { public final void setMayPlay(final Player player, final boolean withoutManaCost, final boolean ignoreColor, final boolean withFlash) {
final CardPlayOption option = this.mayPlay.get(player); final CardPlayOption option = this.mayPlay.get(player);
this.mayPlay.put(player, option == null ? new CardPlayOption(withoutManaCost, ignoreColor) : option.add(withoutManaCost, ignoreColor)); this.mayPlay.put(player, option == null ? new CardPlayOption(withoutManaCost, ignoreColor, withFlash) : option.add(withoutManaCost, ignoreColor, withFlash));
} }
public final void removeMayPlay(final Player player) { public final void removeMayPlay(final Player player) {
this.mayPlay.remove(player); this.mayPlay.remove(player);

View File

@@ -21,17 +21,19 @@ public final class CardPlayOption {
private final PayManaCost payManaCost; private final PayManaCost payManaCost;
private final boolean ignoreManaCostColor; private final boolean ignoreManaCostColor;
private final boolean withFlash;
public CardPlayOption(final boolean withoutManaCost, final boolean ignoreManaCostColor) { public CardPlayOption(final boolean withoutManaCost, final boolean ignoreManaCostColor, final boolean withFlash) {
this(withoutManaCost ? PayManaCost.NO : PayManaCost.YES, ignoreManaCostColor); this(withoutManaCost ? PayManaCost.NO : PayManaCost.YES, ignoreManaCostColor, withFlash);
} }
private CardPlayOption(final PayManaCost payManaCost, final boolean ignoreManaCostColor) { private CardPlayOption(final PayManaCost payManaCost, final boolean ignoreManaCostColor, final boolean withFlash) {
this.payManaCost = payManaCost; this.payManaCost = payManaCost;
this.ignoreManaCostColor = ignoreManaCostColor; this.ignoreManaCostColor = ignoreManaCostColor;
this.withFlash = withFlash;
} }
public CardPlayOption add(final boolean payManaCost, final boolean ignoreManaCostColor) { public CardPlayOption add(final boolean payManaCost, final boolean ignoreManaCostColor, final boolean withFlash) {
return new CardPlayOption(this.payManaCost.add(payManaCost), isIgnoreManaCostColor() || ignoreManaCostColor); return new CardPlayOption(this.payManaCost.add(payManaCost), isIgnoreManaCostColor() || ignoreManaCostColor, isWithFlash() || withFlash);
} }
public PayManaCost getPayManaCost() { public PayManaCost getPayManaCost() {
@@ -42,6 +44,10 @@ public final class CardPlayOption {
return ignoreManaCostColor; return ignoreManaCostColor;
} }
public boolean isWithFlash() {
return withFlash;
}
@Override @Override
public String toString() { public String toString() {
switch (getPayManaCost()) { switch (getPayManaCost()) {
@@ -57,7 +63,11 @@ public final class CardPlayOption {
return " (with or without paying its mana cost)"; return " (with or without paying its mana cost)";
} }
case NO: case NO:
return " (without paying its mana cost)"; if (isWithFlash()) {
return " (without paying its mana cost and as though it has flash)";
} else {
return " (without paying its mana cost)";
}
} }
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }

View File

@@ -29,9 +29,7 @@ import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.GameCommand; import forge.GameCommand;
import forge.card.ColorSet;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.card.mana.ManaCostShard;
import forge.game.Game; import forge.game.Game;
import forge.game.GlobalRuleChange; import forge.game.GlobalRuleChange;
import forge.game.StaticEffect; import forge.game.StaticEffect;
@@ -140,7 +138,7 @@ public final class StaticAbilityContinuous {
boolean removeSubTypes = false; boolean removeSubTypes = false;
boolean removeCreatureTypes = false; boolean removeCreatureTypes = false;
boolean controllerMayLookAt = false; boolean controllerMayLookAt = false;
boolean controllerMayPlay = false, mayPlayWithoutManaCost = false, mayPlayIgnoreColor = false; boolean controllerMayPlay = false, mayPlayWithoutManaCost = false, mayPlayIgnoreColor = false, mayPlayWithFlash = false;
//Global rules changes //Global rules changes
if (layer == StaticAbilityLayer.RULES && params.containsKey("GlobalRule")) { if (layer == StaticAbilityLayer.RULES && params.containsKey("GlobalRule")) {
@@ -376,6 +374,9 @@ public final class StaticAbilityContinuous {
} else if (params.containsKey("MayPlayIgnoreColor")) { } else if (params.containsKey("MayPlayIgnoreColor")) {
mayPlayIgnoreColor = true; mayPlayIgnoreColor = true;
} }
if (params.containsKey("MayPlayWithFlash")) {
mayPlayWithFlash = true;
}
} }
if (params.containsKey("IgnoreEffectCost")) { if (params.containsKey("IgnoreEffectCost")) {
@@ -611,7 +612,7 @@ public final class StaticAbilityContinuous {
affectedCard.setMayLookAt(controller, true); affectedCard.setMayLookAt(controller, true);
} }
if (controllerMayPlay) { if (controllerMayPlay) {
affectedCard.setMayPlay(controller, mayPlayWithoutManaCost, mayPlayIgnoreColor); affectedCard.setMayPlay(controller, mayPlayWithoutManaCost, mayPlayIgnoreColor, mayPlayWithFlash);
} }
affectedCard.updateStateForView(); affectedCard.updateStateForView();