mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Fix text-changing Possessed Aven.
This commit is contained in:
@@ -43,6 +43,9 @@ public abstract class CardTraitBase extends GameObject {
|
||||
/** Keys of descriptive (text) parameters. */
|
||||
private static final ImmutableList<String> descriptiveKeys = ImmutableList.<String>builder()
|
||||
.add("Description", "SpellDescription", "StackDescription", "TriggerDescription").build();
|
||||
/** Keys to be followed as SVar names when changing text. */
|
||||
private static final ImmutableList<String> mutableKeys = ImmutableList.<String>builder()
|
||||
.add("AddAbility").build();
|
||||
|
||||
/**
|
||||
* Sets the temporary.
|
||||
@@ -357,15 +360,19 @@ public abstract class CardTraitBase extends GameObject {
|
||||
public void changeText() {
|
||||
for (final String key : this.mapParams.keySet()) {
|
||||
final String value = this.originalMapParams.get(key), newValue;
|
||||
// change descriptions differently
|
||||
if (descriptiveKeys.contains(key)) {
|
||||
// change descriptions differently
|
||||
newValue = AbilityUtils.applyDescriptionTextChangeEffects(value, this);
|
||||
}
|
||||
// don't change literal SVar names!
|
||||
else if (!this.getHostCard().hasSVar(key)) {
|
||||
newValue = AbilityUtils.applyAbilityTextChangeEffects(value, this);
|
||||
} else {
|
||||
} else if (mutableKeys.contains(key)) {
|
||||
// follow SVar and change it
|
||||
final String originalSVarValue = hostCard.getSVar(value);
|
||||
hostCard.changeSVar(value, AbilityUtils.applyAbilityTextChangeEffects(originalSVarValue, this));
|
||||
newValue = null;
|
||||
} else if (this.getHostCard().hasSVar(value)) {
|
||||
// don't change literal SVar names!
|
||||
newValue = null;
|
||||
} else {
|
||||
newValue = AbilityUtils.applyAbilityTextChangeEffects(value, this);
|
||||
}
|
||||
|
||||
if (newValue != null) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forge.GameCommand;
|
||||
@@ -123,6 +124,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
private final CardChangedWords changedTextTypes = new CardChangedWords();
|
||||
/** List of the keywords that have been added by text changes. */
|
||||
private final List<String> keywordsGrantedByTextChanges = Lists.newArrayList();
|
||||
/** Original values of SVars changed by text changes. */
|
||||
private Map<String, String> originalSVars = Maps.newHashMap();
|
||||
|
||||
private final ArrayList<Object> rememberedObjects = new ArrayList<Object>();
|
||||
private final MapOfLists<GameEntity, Object> rememberMap = new HashMapOfLists<GameEntity, Object>(CollectionSuppliers.<Object>arrayLists());
|
||||
@@ -4609,6 +4612,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* Update the changed text of the intrinsic spell abilities and keywords.
|
||||
*/
|
||||
private final void updateChangedText() {
|
||||
resetChangedSVars();
|
||||
final List<CardTraitBase> allAbs = ImmutableList.<CardTraitBase>builder()
|
||||
.addAll(this.getSpellAbilities())
|
||||
.addAll(this.getStaticAbilities())
|
||||
@@ -4640,6 +4644,26 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
this.changedTextTypes.copyFrom(other.changedTextTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change a SVar due to a text change effect. Change is volatile and will be
|
||||
* reverted upon refreshing text changes (unless it is changed again at that
|
||||
* time).
|
||||
*
|
||||
* @param key the SVar name.
|
||||
* @param value the new SVar value.
|
||||
*/
|
||||
public final void changeSVar(final String key, final String value) {
|
||||
originalSVars.put(key, getSVar(key));
|
||||
this.setSVar(key, value);
|
||||
}
|
||||
|
||||
private void resetChangedSVars() {
|
||||
for (final Entry<String, String> svar : originalSVars.entrySet()) {
|
||||
this.setSVar(svar.getKey(), svar.getValue());
|
||||
}
|
||||
originalSVars.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getIntrinsicAbilities.
|
||||
|
||||
Reference in New Issue
Block a user