mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Add Swirl the Mists (plus some general text change cleanup).
This commit is contained in:
@@ -87,6 +87,8 @@ public class StaticEffects implements IGameStateObject {
|
||||
final ArrayList<Player> affectedPlayers = se.getAffectedPlayers();
|
||||
final Map<String, String> params = se.getParams();
|
||||
|
||||
String changeColorWordsTo = null;
|
||||
|
||||
int powerBonus = 0;
|
||||
String addP = "";
|
||||
int toughnessBonus = 0;
|
||||
@@ -97,6 +99,10 @@ public class StaticEffects implements IGameStateObject {
|
||||
String[] addHiddenKeywords = null;
|
||||
String addColors = null;
|
||||
|
||||
if (params.containsKey("ChangeColorWordsTo")) {
|
||||
changeColorWordsTo = params.get("ChangeColorWordsTo");
|
||||
}
|
||||
|
||||
if (params.containsKey("SetPower") || params.containsKey("SetToughness")) {
|
||||
setPT = true;
|
||||
}
|
||||
@@ -188,6 +194,11 @@ public class StaticEffects implements IGameStateObject {
|
||||
affectedCard.removeTempController(se.getTimestamp());
|
||||
}
|
||||
|
||||
// Revert changed color words
|
||||
if (changeColorWordsTo != null) {
|
||||
affectedCard.removeChangedTextColorWord(se.getTimestamp());
|
||||
}
|
||||
|
||||
// remove set P/T
|
||||
if (!params.containsKey("CharacteristicDefining") && setPT) {
|
||||
affectedCard.removeNewPT(se.getTimestamp());
|
||||
|
||||
@@ -1517,7 +1517,14 @@ public class AbilityUtils {
|
||||
public static final String applyTextChangeEffects(final String def, final Card hostCard) {
|
||||
String replaced = def;
|
||||
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()) {
|
||||
replaced = replaced.replace(e.getKey(), e.getValue());
|
||||
|
||||
@@ -24,6 +24,7 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
||||
public void resolve(final SpellAbility sa) {
|
||||
final Card source = sa.getHostCard();
|
||||
final Game game = source.getGame();
|
||||
final Long timestamp = Long.valueOf(game.getNextTimestamp());
|
||||
final boolean permanent = sa.hasParam("Permanent");
|
||||
|
||||
final String changedColorWordOriginal, changedColorWordNew;
|
||||
@@ -97,19 +98,8 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
||||
|
||||
final List<Card> tgts = getTargetCards(sa);
|
||||
for (final Card c : tgts) {
|
||||
final Long colorTimestamp;
|
||||
if (changedColorWordNew != null) {
|
||||
colorTimestamp = c.addChangedTextColorWord(changedColorWordOriginal, changedColorWordNew);
|
||||
} else {
|
||||
colorTimestamp = null;
|
||||
}
|
||||
|
||||
final Long typeTimestamp;
|
||||
if (changedTypeWordNew != null) {
|
||||
typeTimestamp = c.addChangedTextTypeWord(changedTypeWordOriginal, changedTypeWordNew);
|
||||
} else {
|
||||
typeTimestamp = null;
|
||||
}
|
||||
c.addChangedTextColorWord(changedColorWordOriginal, changedColorWordNew, timestamp);
|
||||
c.addChangedTextTypeWord(changedTypeWordOriginal, changedTypeWordNew, timestamp);
|
||||
|
||||
if (!permanent) {
|
||||
final GameCommand revert = new GameCommand() {
|
||||
@@ -117,10 +107,10 @@ public class ChangeTextEffect extends SpellAbilityEffect {
|
||||
@Override
|
||||
public void run() {
|
||||
if (changedColorWordNew != null) {
|
||||
c.removeChangedTextColorWord(colorTimestamp);
|
||||
c.removeChangedTextColorWord(timestamp);
|
||||
}
|
||||
if (changedTypeWordNew != null) {
|
||||
c.removeChangedTextTypeWord(typeTimestamp);
|
||||
c.removeChangedTextTypeWord(timestamp);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4544,14 +4544,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* @throws RuntimeException if either of the strings is not a valid Magic
|
||||
* 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) {
|
||||
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.updateChangedText();
|
||||
return 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 newWord the new type word.
|
||||
*/
|
||||
public final Long addChangedTextTypeWord(final String originalWord, final String newWord) {
|
||||
final Long timestamp = this.changedTextTypes.add(this.getGame().getNextTimestamp(), originalWord, newWord);
|
||||
public final void addChangedTextTypeWord(final String originalWord, final String newWord, final Long timestamp) {
|
||||
this.changedTextTypes.add(timestamp, originalWord, newWord);
|
||||
if (this.getType().contains(originalWord)) {
|
||||
this.addChangedCardTypes(Lists.newArrayList(newWord), Lists.newArrayList(originalWord), false, false, false, false, timestamp);
|
||||
}
|
||||
this.updateKeywordsChangedText(originalWord, newWord, timestamp);
|
||||
this.updateChangedText();
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public final void removeChangedTextTypeWord(final Long timestamp) {
|
||||
|
||||
@@ -53,7 +53,9 @@ public final class CardChangedWords {
|
||||
resultCache.put(ccw.getOriginalWord(), ccw.getNewWord());
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class StaticAbility extends CardTraitBase {
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (this.mapParams.containsKey("ChangeText")) {
|
||||
if (this.mapParams.containsKey("ChangeColorWordsTo")) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.collect.Lists;
|
||||
import forge.GameCommand;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.game.*;
|
||||
import forge.game.ability.AbilityFactory;
|
||||
@@ -79,6 +80,8 @@ public class StaticAbilityContinuous {
|
||||
se.setTimestamp(hostCard.getTimestamp());
|
||||
game.getStaticEffects().addStaticEffect(se);
|
||||
|
||||
String changeColorWordsTo = null;
|
||||
|
||||
String addP = "";
|
||||
int powerBonus = 0;
|
||||
String addT = "";
|
||||
@@ -113,6 +116,10 @@ public class StaticAbilityContinuous {
|
||||
effects.setGlobalRuleChange(GlobalRuleChange.fromString(params.get("GlobalRule")));
|
||||
}
|
||||
|
||||
if (params.containsKey("ChangeColorWordsTo")) {
|
||||
changeColorWordsTo = params.get("ChangeColorWordsTo");
|
||||
}
|
||||
|
||||
if (params.containsKey("SetPower")) {
|
||||
setP = params.get("SetPower");
|
||||
setPower = AbilityUtils.calculateAmount(hostCard, setP, null);
|
||||
@@ -367,6 +374,25 @@ public class StaticAbilityContinuous {
|
||||
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
|
||||
if (params.containsKey("CharacteristicDefining")) {
|
||||
if (setPower != -1) {
|
||||
|
||||
Reference in New Issue
Block a user