Add Swirl the Mists (plus some general text change cleanup).

This commit is contained in:
elcnesh
2014-08-11 21:31:11 +00:00
parent 4c20cab69c
commit 584eefbfe7
9 changed files with 67 additions and 24 deletions

1
.gitattributes vendored
View File

@@ -13219,6 +13219,7 @@ forge-gui/res/cardsfolder/s/swift_justice.txt -text
forge-gui/res/cardsfolder/s/swift_maneuver.txt svneol=native#text/plain forge-gui/res/cardsfolder/s/swift_maneuver.txt svneol=native#text/plain
forge-gui/res/cardsfolder/s/swift_silence.txt -text forge-gui/res/cardsfolder/s/swift_silence.txt -text
forge-gui/res/cardsfolder/s/swiftfoot_boots.txt svneol=native#text/plain forge-gui/res/cardsfolder/s/swiftfoot_boots.txt svneol=native#text/plain
forge-gui/res/cardsfolder/s/swirl_the_mists.txt -text
forge-gui/res/cardsfolder/s/swirling_sandstorm.txt svneol=native#text/plain forge-gui/res/cardsfolder/s/swirling_sandstorm.txt svneol=native#text/plain
forge-gui/res/cardsfolder/s/swirling_spriggan.txt -text forge-gui/res/cardsfolder/s/swirling_spriggan.txt -text
forge-gui/res/cardsfolder/s/switcheroo.txt -text forge-gui/res/cardsfolder/s/switcheroo.txt -text

View File

@@ -87,6 +87,8 @@ public class StaticEffects implements IGameStateObject {
final ArrayList<Player> affectedPlayers = se.getAffectedPlayers(); final ArrayList<Player> affectedPlayers = se.getAffectedPlayers();
final Map<String, String> params = se.getParams(); final Map<String, String> params = se.getParams();
String changeColorWordsTo = null;
int powerBonus = 0; int powerBonus = 0;
String addP = ""; String addP = "";
int toughnessBonus = 0; int toughnessBonus = 0;
@@ -97,6 +99,10 @@ public class StaticEffects implements IGameStateObject {
String[] addHiddenKeywords = null; String[] addHiddenKeywords = null;
String addColors = null; String addColors = null;
if (params.containsKey("ChangeColorWordsTo")) {
changeColorWordsTo = params.get("ChangeColorWordsTo");
}
if (params.containsKey("SetPower") || params.containsKey("SetToughness")) { if (params.containsKey("SetPower") || params.containsKey("SetToughness")) {
setPT = true; setPT = true;
} }
@@ -188,6 +194,11 @@ public class StaticEffects implements IGameStateObject {
affectedCard.removeTempController(se.getTimestamp()); affectedCard.removeTempController(se.getTimestamp());
} }
// Revert changed color words
if (changeColorWordsTo != null) {
affectedCard.removeChangedTextColorWord(se.getTimestamp());
}
// remove set P/T // remove set P/T
if (!params.containsKey("CharacteristicDefining") && setPT) { if (!params.containsKey("CharacteristicDefining") && setPT) {
affectedCard.removeNewPT(se.getTimestamp()); affectedCard.removeNewPT(se.getTimestamp());

View File

@@ -1517,7 +1517,14 @@ public class AbilityUtils {
public static final String applyTextChangeEffects(final String def, final Card hostCard) { public static final String applyTextChangeEffects(final String def, final Card hostCard) {
String replaced = def; String replaced = def;
for (final Entry<String, String> e : hostCard.getChangedTextColorWords().entrySet()) { for (final Entry<String, String> e : hostCard.getChangedTextColorWords().entrySet()) {
replaced = replaced.replace(e.getKey(), e.getValue()); if (e.getKey().equals("Any")) {
for (final byte c : MagicColor.WUBRG) {
replaced = replaced.replace(MagicColor.toLongString(c), e.getValue())
.replace(StringUtils.capitalize(MagicColor.toLongString(c)), StringUtils.capitalize(e.getValue()));
}
} else {
replaced = replaced.replace(e.getKey(), e.getValue());
}
} }
for (final Entry<String, String> e : hostCard.getChangedTextTypeWords().entrySet()) { for (final Entry<String, String> e : hostCard.getChangedTextTypeWords().entrySet()) {
replaced = replaced.replace(e.getKey(), e.getValue()); replaced = replaced.replace(e.getKey(), e.getValue());

View File

@@ -24,6 +24,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
public void resolve(final SpellAbility sa) { public void resolve(final SpellAbility sa) {
final Card source = sa.getHostCard(); final Card source = sa.getHostCard();
final Game game = source.getGame(); final Game game = source.getGame();
final Long timestamp = Long.valueOf(game.getNextTimestamp());
final boolean permanent = sa.hasParam("Permanent"); final boolean permanent = sa.hasParam("Permanent");
final String changedColorWordOriginal, changedColorWordNew; final String changedColorWordOriginal, changedColorWordNew;
@@ -97,19 +98,8 @@ public class ChangeTextEffect extends SpellAbilityEffect {
final List<Card> tgts = getTargetCards(sa); final List<Card> tgts = getTargetCards(sa);
for (final Card c : tgts) { for (final Card c : tgts) {
final Long colorTimestamp; c.addChangedTextColorWord(changedColorWordOriginal, changedColorWordNew, timestamp);
if (changedColorWordNew != null) { c.addChangedTextTypeWord(changedTypeWordOriginal, changedTypeWordNew, timestamp);
colorTimestamp = c.addChangedTextColorWord(changedColorWordOriginal, changedColorWordNew);
} else {
colorTimestamp = null;
}
final Long typeTimestamp;
if (changedTypeWordNew != null) {
typeTimestamp = c.addChangedTextTypeWord(changedTypeWordOriginal, changedTypeWordNew);
} else {
typeTimestamp = null;
}
if (!permanent) { if (!permanent) {
final GameCommand revert = new GameCommand() { final GameCommand revert = new GameCommand() {
@@ -117,10 +107,10 @@ public class ChangeTextEffect extends SpellAbilityEffect {
@Override @Override
public void run() { public void run() {
if (changedColorWordNew != null) { if (changedColorWordNew != null) {
c.removeChangedTextColorWord(colorTimestamp); c.removeChangedTextColorWord(timestamp);
} }
if (changedTypeWordNew != null) { if (changedTypeWordNew != null) {
c.removeChangedTextTypeWord(typeTimestamp); c.removeChangedTextTypeWord(timestamp);
} }
} }
}; };

View File

@@ -4544,14 +4544,13 @@ public class Card extends GameEntity implements Comparable<Card> {
* @throws RuntimeException if either of the strings is not a valid Magic * @throws RuntimeException if either of the strings is not a valid Magic
* color. * color.
*/ */
public final Long addChangedTextColorWord(final String originalWord, final String newWord) { public final void addChangedTextColorWord(final String originalWord, final String newWord, final Long timestamp) {
if (MagicColor.fromName(newWord) == 0) { if (MagicColor.fromName(newWord) == 0) {
throw new RuntimeException("Not a color: " + newWord); throw new RuntimeException("Not a color: " + newWord);
} }
final Long timestamp = this.changedTextColors.add(this.getGame().getNextTimestamp(), originalWord, newWord); this.changedTextColors.add(timestamp, StringUtils.capitalize(originalWord), StringUtils.capitalize(newWord));
this.updateKeywordsChangedText(originalWord, newWord, timestamp); this.updateKeywordsChangedText(originalWord, newWord, timestamp);
this.updateChangedText(); this.updateChangedText();
return timestamp;
} }
public final void removeChangedTextColorWord(final Long timestamp) { public final void removeChangedTextColorWord(final Long timestamp) {
@@ -4566,14 +4565,13 @@ public class Card extends GameEntity implements Comparable<Card> {
* @param originalWord the original type word. * @param originalWord the original type word.
* @param newWord the new type word. * @param newWord the new type word.
*/ */
public final Long addChangedTextTypeWord(final String originalWord, final String newWord) { public final void addChangedTextTypeWord(final String originalWord, final String newWord, final Long timestamp) {
final Long timestamp = this.changedTextTypes.add(this.getGame().getNextTimestamp(), originalWord, newWord); this.changedTextTypes.add(timestamp, originalWord, newWord);
if (this.getType().contains(originalWord)) { if (this.getType().contains(originalWord)) {
this.addChangedCardTypes(Lists.newArrayList(newWord), Lists.newArrayList(originalWord), false, false, false, false, timestamp); this.addChangedCardTypes(Lists.newArrayList(newWord), Lists.newArrayList(originalWord), false, false, false, false, timestamp);
} }
this.updateKeywordsChangedText(originalWord, newWord, timestamp); this.updateKeywordsChangedText(originalWord, newWord, timestamp);
this.updateChangedText(); this.updateChangedText();
return timestamp;
} }
public final void removeChangedTextTypeWord(final Long timestamp) { public final void removeChangedTextTypeWord(final Long timestamp) {

View File

@@ -53,7 +53,9 @@ public final class CardChangedWords {
resultCache.put(ccw.getOriginalWord(), ccw.getNewWord()); resultCache.put(ccw.getOriginalWord(), ccw.getNewWord());
} }
for (final String key : ImmutableList.copyOf(resultCache.keySet())) { for (final String key : ImmutableList.copyOf(resultCache.keySet())) {
resultCache.put(key.toLowerCase(), resultCache.get(key).toLowerCase()); if (!key.equals("Any")) {
resultCache.put(key.toLowerCase(), resultCache.get(key).toLowerCase());
}
} }
isDirty = false; isDirty = false;
} }

View File

@@ -111,7 +111,7 @@ public class StaticAbility extends CardTraitBase {
return 2; return 2;
} }
if (this.mapParams.containsKey("ChangeText")) { if (this.mapParams.containsKey("ChangeColorWordsTo")) {
return 3; return 3;
} }

View File

@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
import forge.GameCommand; import forge.GameCommand;
import forge.card.CardType; import forge.card.CardType;
import forge.card.ColorSet; import forge.card.ColorSet;
import forge.card.MagicColor;
import forge.card.mana.ManaCostShard; import forge.card.mana.ManaCostShard;
import forge.game.*; import forge.game.*;
import forge.game.ability.AbilityFactory; import forge.game.ability.AbilityFactory;
@@ -79,6 +80,8 @@ public class StaticAbilityContinuous {
se.setTimestamp(hostCard.getTimestamp()); se.setTimestamp(hostCard.getTimestamp());
game.getStaticEffects().addStaticEffect(se); game.getStaticEffects().addStaticEffect(se);
String changeColorWordsTo = null;
String addP = ""; String addP = "";
int powerBonus = 0; int powerBonus = 0;
String addT = ""; String addT = "";
@@ -113,6 +116,10 @@ public class StaticAbilityContinuous {
effects.setGlobalRuleChange(GlobalRuleChange.fromString(params.get("GlobalRule"))); effects.setGlobalRuleChange(GlobalRuleChange.fromString(params.get("GlobalRule")));
} }
if (params.containsKey("ChangeColorWordsTo")) {
changeColorWordsTo = params.get("ChangeColorWordsTo");
}
if (params.containsKey("SetPower")) { if (params.containsKey("SetPower")) {
setP = params.get("SetPower"); setP = params.get("SetPower");
setPower = AbilityUtils.calculateAmount(hostCard, setP, null); setPower = AbilityUtils.calculateAmount(hostCard, setP, null);
@@ -367,6 +374,25 @@ public class StaticAbilityContinuous {
affectedCard.addTempController(hostCard.getController(), hostCard.getTimestamp()); affectedCard.addTempController(hostCard.getController(), hostCard.getTimestamp());
} }
// Change color words
if (changeColorWordsTo != null) {
final byte color;
if (changeColorWordsTo.equals("ChosenColor")) {
if (hostCard.getChosenColor().size() > 0) {
color = MagicColor.fromName(hostCard.getChosenColor().get(0));
} else {
color = 0;
}
} else {
color = MagicColor.fromName(changeColorWordsTo);
}
if (color != 0) {
final String colorName = MagicColor.toLongString(color);
affectedCard.addChangedTextColorWord("Any", colorName, se.getTimestamp());
}
}
// set P/T // set P/T
if (params.containsKey("CharacteristicDefining")) { if (params.containsKey("CharacteristicDefining")) {
if (setPower != -1) { if (setPower != -1) {

View File

@@ -0,0 +1,8 @@
Name:Swirl the Mists
ManaCost:2 U U
Types:Enchantment
K:ETBReplacement:Other:ChooseColor
SVar:ChooseColor:DB$ ChooseColor | Defined$ You | SpellDescription$ As CARDNAME enters the battlefield, choose a color word.
S:Mode$ Continuous | Affected$ Spell,Permanent | AffectedZone$ Stack,Battlefield | ChangeColorWordsTo$ ChosenColor | Description$ All instances of color words in the text of spells and permanents are changed to the chosen color word.
SVar:Picture:http://www.wizards.com/global/images/magic/general/swirl_the_mists.jpg
Oracle:As Swirl the Mists enters the battlefield, choose a color word.\nAll instances of color words in the text of spells and permanents are changed to the chosen color word.