Merge branch 'gristFixes' into 'master'

Card: fix getType when using changedCardTypesCharacterDefining

See merge request core-developers/forge!4984
This commit is contained in:
Hans Mackowiak
2021-07-11 15:15:55 +00:00
5 changed files with 42 additions and 12 deletions

View File

@@ -285,8 +285,12 @@ public class GameCopier {
}
newCard.setPTBoost(c.getPTBoostTable());
newCard.setDamage(c.getDamage());
newCard.setChangedCardColors(c.getChangedCardColorsMap());
newCard.setChangedCardColorsCharacterDefining(c.getChangedCardColorsCharacterDefiningMap());
newCard.setChangedCardTypes(c.getChangedCardTypesMap());
newCard.setChangedCardTypesCharacterDefining(c.getChangedCardTypesCharacterDefiningMap());
newCard.setChangedCardKeywords(c.getChangedCardKeywords());
newCard.setChangedCardNames(c.getChangedCardNames());

View File

@@ -244,9 +244,11 @@ public class GameAction {
if (zoneTo.is(ZoneType.Stack)) {
// when moving to stack, copy changed card information
copied.setChangedCardColors(c.getChangedCardColors());
copied.setChangedCardColors(c.getChangedCardColorsMap());
copied.setChangedCardColorsCharacterDefining(c.getChangedCardColorsCharacterDefiningMap());
copied.setChangedCardKeywords(c.getChangedCardKeywords());
copied.setChangedCardTypes(c.getChangedCardTypesMap());
copied.setChangedCardTypesCharacterDefining(c.getChangedCardTypesCharacterDefiningMap());
copied.setChangedCardNames(c.getChangedCardNames());
copied.setChangedCardTraits(c.getChangedCardTraits());
@@ -266,6 +268,9 @@ public class GameAction {
// on Transformed objects)
copied.setState(CardStateName.Original, false);
copied.setBackSide(false);
// reset timestamp in changezone effects so they have same timestamp if ETB simutaneously
copied.setTimestamp(game.getNextTimestamp());
}
copied.setUnearthed(c.isUnearthed());
@@ -278,6 +283,7 @@ public class GameAction {
}
} else { //Token
copied = c;
copied.setTimestamp(game.getNextTimestamp());
}
}
@@ -603,8 +609,6 @@ public class GameAction {
}
unattachCardLeavingBattlefield(copied);
} else if (toBattlefield) {
// reset timestamp in changezone effects so they have same timestamp if ETB simutaneously
copied.setTimestamp(game.getNextTimestamp());
for (Player p : game.getPlayers()) {
copied.getDamageHistory().setNotAttackedSinceLastUpkeepOf(p);
copied.getDamageHistory().setNotBlockedSinceLastUpkeepOf(p);
@@ -619,7 +623,6 @@ public class GameAction {
|| zoneTo.is(ZoneType.Hand)
|| zoneTo.is(ZoneType.Library)
|| zoneTo.is(ZoneType.Exile)) {
copied.setTimestamp(game.getNextTimestamp());
copied.clearOptionalCostsPaid();
if (copied.isFaceDown()) {
copied.setState(CardStateName.Original, true);

View File

@@ -3495,7 +3495,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
}
public final CardTypeView getType(CardState state) {
if (changedCardTypes.isEmpty()) {
if (changedCardTypes.isEmpty() && changedCardTypesCharacterDefining.isEmpty()) {
return state.getType();
}
return state.getType().getTypeWithChanges(getChangedCardTypes());
@@ -3508,6 +3508,9 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public Map<Long, CardChangedType> getChangedCardTypesMap() {
return Collections.unmodifiableMap(changedCardTypes);
}
public Map<Long, CardChangedType> getChangedCardTypesCharacterDefiningMap() {
return Collections.unmodifiableMap(changedCardTypesCharacterDefining);
}
public boolean clearChangedCardTypes() {
boolean changed = false;
@@ -3548,9 +3551,15 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
return changedCardKeywords;
}
public Map<Long, CardColor> getChangedCardColors() {
public Map<Long, CardColor> getChangedCardColorsMap() {
return changedCardColors;
}
public Map<Long, CardColor> getChangedCardColorsCharacterDefiningMap() {
return changedCardColorsCharacterDefining;
}
public Iterable<CardColor> getChangedCardColors() {
return Iterables.concat(changedCardColorsCharacterDefining.values(), changedCardColors.values());
}
public final void addChangedCardTypes(final CardType addType, final CardType removeType,
final boolean removeSuperTypes, final boolean removeCardTypes, final boolean removeSubTypes,
@@ -3602,7 +3611,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
public final void addColor(final String s, final boolean addToColors, final long timestamp, final boolean cda) {
(cda ? changedCardColorsCharacterDefining : changedCardColors).put(timestamp, new CardColor(s, addToColors, timestamp));
currentState.getView().updateColors(this);
currentState.getView().updateHasChangeColors(!getChangedCardColors().isEmpty());
currentState.getView().updateHasChangeColors(!Iterables.isEmpty(getChangedCardColors()));
}
public final void removeColor(final long timestampIn) {
@@ -3612,7 +3621,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
if (removed) {
currentState.getView().updateColors(this);
currentState.getView().updateHasChangeColors(!getChangedCardColors().isEmpty());
currentState.getView().updateHasChangeColors(!Iterables.isEmpty(getChangedCardColors()));
}
}
@@ -3628,7 +3637,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
}
public final ColorSet determineColor(CardState state) {
byte colors = state.getColor();
for (final CardColor cc : Iterables.concat(changedCardColorsCharacterDefining.values(), changedCardColors.values())) {
for (final CardColor cc : getChangedCardColors()) {
if (cc.isAdditional()) {
colors |= cc.getColorMask();
} else {
@@ -6604,6 +6613,12 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
this.changedCardTypes.put(entry.getKey(), entry.getValue());
}
}
public void setChangedCardTypesCharacterDefining(Map<Long, CardChangedType> changedCardTypes) {
this.changedCardTypesCharacterDefining.clear();
for (Entry<Long, CardChangedType> entry : changedCardTypes.entrySet()) {
this.changedCardTypesCharacterDefining.put(entry.getKey(), entry.getValue());
}
}
public void setChangedCardKeywords(Map<Long, KeywordsChange> changedCardKeywords) {
this.changedCardKeywords.clear();
@@ -6618,6 +6633,12 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
this.changedCardColors.put(entry.getKey(), entry.getValue());
}
}
public void setChangedCardColorsCharacterDefining(Map<Long, CardColor> changedCardColors) {
this.changedCardColorsCharacterDefining.clear();
for (Entry<Long, CardColor> entry : changedCardColors.entrySet()) {
this.changedCardColorsCharacterDefining.put(entry.getKey(), entry.getValue());
}
}
public void forceTurnFaceUp() {
getGame().getTriggerHandler().suppressMode(TriggerType.TurnFaceUp);

View File

@@ -281,9 +281,11 @@ public final class CardUtil {
newCopy.setUnearthed(in.isUnearthed());
newCopy.setChangedCardColors(in.getChangedCardColors());
newCopy.setChangedCardColors(in.getChangedCardColorsMap());
newCopy.setChangedCardColorsCharacterDefining(in.getChangedCardColorsCharacterDefiningMap());
newCopy.setChangedCardKeywords(in.getChangedCardKeywords());
newCopy.setChangedCardTypes(in.getChangedCardTypesMap());
newCopy.setChangedCardTypesCharacterDefining(in.getChangedCardTypesCharacterDefiningMap());
newCopy.setChangedCardNames(in.getChangedCardNames());
newCopy.setChangedCardTraits(in.getChangedCardTraits());

View File

@@ -869,7 +869,7 @@ public class CardView extends GameEntityView {
// update the color only while in Game
if (c.getGame() != null) {
currentStateView.updateColors(currentState);
currentStateView.updateHasChangeColors(!c.getChangedCardColors().isEmpty());
currentStateView.updateHasChangeColors(!Iterables.isEmpty(c.getChangedCardColors()));
}
} else {
currentStateView.updateLoyalty(currentState);