mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28: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. */
|
/** Keys of descriptive (text) parameters. */
|
||||||
private static final ImmutableList<String> descriptiveKeys = ImmutableList.<String>builder()
|
private static final ImmutableList<String> descriptiveKeys = ImmutableList.<String>builder()
|
||||||
.add("Description", "SpellDescription", "StackDescription", "TriggerDescription").build();
|
.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.
|
* Sets the temporary.
|
||||||
@@ -357,15 +360,19 @@ public abstract class CardTraitBase extends GameObject {
|
|||||||
public void changeText() {
|
public void changeText() {
|
||||||
for (final String key : this.mapParams.keySet()) {
|
for (final String key : this.mapParams.keySet()) {
|
||||||
final String value = this.originalMapParams.get(key), newValue;
|
final String value = this.originalMapParams.get(key), newValue;
|
||||||
// change descriptions differently
|
|
||||||
if (descriptiveKeys.contains(key)) {
|
if (descriptiveKeys.contains(key)) {
|
||||||
|
// change descriptions differently
|
||||||
newValue = AbilityUtils.applyDescriptionTextChangeEffects(value, this);
|
newValue = AbilityUtils.applyDescriptionTextChangeEffects(value, this);
|
||||||
}
|
} else if (mutableKeys.contains(key)) {
|
||||||
// don't change literal SVar names!
|
// follow SVar and change it
|
||||||
else if (!this.getHostCard().hasSVar(key)) {
|
final String originalSVarValue = hostCard.getSVar(value);
|
||||||
newValue = AbilityUtils.applyAbilityTextChangeEffects(value, this);
|
hostCard.changeSVar(value, AbilityUtils.applyAbilityTextChangeEffects(originalSVarValue, this));
|
||||||
} else {
|
|
||||||
newValue = null;
|
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) {
|
if (newValue != null) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.common.base.Function;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import forge.GameCommand;
|
import forge.GameCommand;
|
||||||
@@ -123,6 +124,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
private final CardChangedWords changedTextTypes = new CardChangedWords();
|
private final CardChangedWords changedTextTypes = new CardChangedWords();
|
||||||
/** List of the keywords that have been added by text changes. */
|
/** List of the keywords that have been added by text changes. */
|
||||||
private final List<String> keywordsGrantedByTextChanges = Lists.newArrayList();
|
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 ArrayList<Object> rememberedObjects = new ArrayList<Object>();
|
||||||
private final MapOfLists<GameEntity, Object> rememberMap = new HashMapOfLists<GameEntity, Object>(CollectionSuppliers.<Object>arrayLists());
|
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.
|
* Update the changed text of the intrinsic spell abilities and keywords.
|
||||||
*/
|
*/
|
||||||
private final void updateChangedText() {
|
private final void updateChangedText() {
|
||||||
|
resetChangedSVars();
|
||||||
final List<CardTraitBase> allAbs = ImmutableList.<CardTraitBase>builder()
|
final List<CardTraitBase> allAbs = ImmutableList.<CardTraitBase>builder()
|
||||||
.addAll(this.getSpellAbilities())
|
.addAll(this.getSpellAbilities())
|
||||||
.addAll(this.getStaticAbilities())
|
.addAll(this.getStaticAbilities())
|
||||||
@@ -4640,6 +4644,26 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
this.changedTextTypes.copyFrom(other.changedTextTypes);
|
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>
|
* <p>
|
||||||
* getIntrinsicAbilities.
|
* getIntrinsicAbilities.
|
||||||
|
|||||||
Reference in New Issue
Block a user