mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Experimental: attempting to fix card flickering (power/toughness, jumping between rows) by selectively updating the view for P/T and types after all static effects for all cards have been processed instead of aggressively updating the entire state view during each static effect operation (might also make the game run a bit faster on mobile).
- Volrath's Shapeshifter: do not copy the target's set code and rarity.
This commit is contained in:
@@ -843,6 +843,12 @@ public class GameAction {
|
|||||||
final Map<String, Object> runParams = Maps.newHashMap();
|
final Map<String, Object> runParams = Maps.newHashMap();
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
game.getTriggerHandler().runTrigger(TriggerType.Always, runParams, false);
|
||||||
|
|
||||||
|
// Update P/T and type in the view only once after all the cards have been processed, to avoid flickering
|
||||||
|
for (Card c : affectedCards) {
|
||||||
|
c.updatePowerToughnessForView();
|
||||||
|
c.updateTypesForView();
|
||||||
|
}
|
||||||
|
|
||||||
if (runEvents && !affectedCards.isEmpty()) {
|
if (runEvents && !affectedCards.isEmpty()) {
|
||||||
game.fireEvent(new GameEventCardStatsChanged(affectedCards));
|
game.fireEvent(new GameEventCardStatsChanged(affectedCards));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1003,8 +1003,9 @@ public class StaticEffect {
|
|||||||
if (addT.startsWith("AffectedX")) {
|
if (addT.startsWith("AffectedX")) {
|
||||||
toughnessBonus = getXMapValue(affectedCard);
|
toughnessBonus = getXMapValue(affectedCard);
|
||||||
}
|
}
|
||||||
affectedCard.addSemiPermanentPowerBoost(powerBonus * -1);
|
// the view is updated in GameAction#checkStaticAbilities to avoid flickering
|
||||||
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus * -1);
|
affectedCard.addSemiPermanentPowerBoost(powerBonus * -1, false);
|
||||||
|
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus * -1, false);
|
||||||
|
|
||||||
// remove keywords
|
// remove keywords
|
||||||
// TODO regular keywords currently don't try to use keyword multiplier
|
// TODO regular keywords currently don't try to use keyword multiplier
|
||||||
@@ -1046,7 +1047,8 @@ public class StaticEffect {
|
|||||||
|
|
||||||
// remove Types
|
// remove Types
|
||||||
if (params.containsKey("AddType") || params.containsKey("RemoveType")) {
|
if (params.containsKey("AddType") || params.containsKey("RemoveType")) {
|
||||||
affectedCard.removeChangedCardTypes(getTimestamp());
|
// the view is updated in GameAction#checkStaticAbilities to avoid flickering
|
||||||
|
affectedCard.removeChangedCardTypes(getTimestamp(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove colors
|
// remove colors
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ public class StaticEffects {
|
|||||||
/**
|
/**
|
||||||
* Add a static effect to the list of static effects.
|
* Add a static effect to the list of static effects.
|
||||||
*
|
*
|
||||||
* @param staticEffect
|
* @param staticAbility
|
||||||
* a {@link StaticEffect}.
|
* a {@link StaticAbility}.
|
||||||
*/
|
*/
|
||||||
public final StaticEffect getStaticEffect(final StaticAbility staticAbility) {
|
public final StaticEffect getStaticEffect(final StaticAbility staticAbility) {
|
||||||
final StaticEffect currentEffect = staticEffects.get(staticAbility);
|
final StaticEffect currentEffect = staticEffects.get(staticAbility);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
|||||||
applyTo.addTempPowerBoost(a);
|
applyTo.addTempPowerBoost(a);
|
||||||
applyTo.addTempToughnessBoost(d);
|
applyTo.addTempToughnessBoost(d);
|
||||||
applyTo.addChangedCardKeywords(kws, Lists.<String>newArrayList(), false, timestamp);
|
applyTo.addChangedCardKeywords(kws, Lists.<String>newArrayList(), false, timestamp);
|
||||||
if (redrawPT) { applyTo.updatePowerToughnessView(); }
|
if (redrawPT) { applyTo.updatePowerToughnessForView(); }
|
||||||
|
|
||||||
if (sa.hasParam("LeaveBattlefield")) {
|
if (sa.hasParam("LeaveBattlefield")) {
|
||||||
addLeaveBattlefieldReplacement(applyTo, sa, sa.getParam("LeaveBattlefield"));
|
addLeaveBattlefieldReplacement(applyTo, sa, sa.getParam("LeaveBattlefield"));
|
||||||
@@ -76,7 +76,7 @@ public class PumpEffect extends SpellAbilityEffect {
|
|||||||
if (kw.startsWith("HIDDEN")) {
|
if (kw.startsWith("HIDDEN")) {
|
||||||
applyTo.removeHiddenExtrinsicKeyword(kw);
|
applyTo.removeHiddenExtrinsicKeyword(kw);
|
||||||
if (redrawPT) {
|
if (redrawPT) {
|
||||||
applyTo.updatePowerToughnessView();
|
applyTo.updatePowerToughnessForView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -456,11 +456,22 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
view.updateState(this);
|
view.updateState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following methods are used to selectively update certain view components (text,
|
||||||
|
// P/T, card types) in order to avoid card flickering due to aggressive full update
|
||||||
public void updateAbilityTextForView() {
|
public void updateAbilityTextForView() {
|
||||||
view.getCurrentState().updateKeywords(this, getCurrentState());
|
view.getCurrentState().updateKeywords(this, getCurrentState());
|
||||||
view.getCurrentState().updateAbilityText(this, getCurrentState());
|
view.getCurrentState().updateAbilityText(this, getCurrentState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void updatePowerToughnessForView() {
|
||||||
|
currentState.getView().updatePower(this);
|
||||||
|
currentState.getView().updateToughness(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void updateTypesForView() {
|
||||||
|
currentState.getView().updateType(currentState);
|
||||||
|
}
|
||||||
|
|
||||||
public void setPreFaceDownState(CardStateName preCharacteristic) {
|
public void setPreFaceDownState(CardStateName preCharacteristic) {
|
||||||
preFaceDownState = preCharacteristic;
|
preFaceDownState = preCharacteristic;
|
||||||
}
|
}
|
||||||
@@ -3129,16 +3140,20 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return semiPermanentToughnessBoost;
|
return semiPermanentToughnessBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addSemiPermanentPowerBoost(final int n) {
|
public final void addSemiPermanentPowerBoost(final int n, final boolean updateViewImmediately) {
|
||||||
if (n == 0) { return; }
|
if (n == 0) { return; }
|
||||||
semiPermanentPowerBoost += n;
|
semiPermanentPowerBoost += n;
|
||||||
currentState.getView().updatePower(this);
|
if (updateViewImmediately) {
|
||||||
|
currentState.getView().updatePower(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void addSemiPermanentToughnessBoost(final int n) {
|
public final void addSemiPermanentToughnessBoost(final int n, final boolean updateViewImmediately) {
|
||||||
if (n == 0) { return; }
|
if (n == 0) { return; }
|
||||||
semiPermanentToughnessBoost += n;
|
semiPermanentToughnessBoost += n;
|
||||||
currentState.getView().updateToughness(this);
|
if (updateViewImmediately) {
|
||||||
|
currentState.getView().updateToughness(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setSemiPermanentPowerBoost(final int n) {
|
public final void setSemiPermanentPowerBoost(final int n) {
|
||||||
@@ -3153,11 +3168,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
currentState.getView().updateToughness(this);
|
currentState.getView().updateToughness(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void updatePowerToughnessView() {
|
|
||||||
currentState.getView().updatePower(this);
|
|
||||||
currentState.getView().updateToughness(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean isUntapped() {
|
public final boolean isUntapped() {
|
||||||
return !tapped;
|
return !tapped;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,6 +496,10 @@ public final class StaticAbilityContinuous {
|
|||||||
|
|
||||||
CardFactory.copyState(gainTextSource, CardStateName.Original, affectedCard, CardStateName.Original, false);
|
CardFactory.copyState(gainTextSource, CardStateName.Original, affectedCard, CardStateName.Original, false);
|
||||||
|
|
||||||
|
// Do not clone the set code and rarity from the target card
|
||||||
|
affectedCard.getState(CardStateName.Original).setSetCode(affectedCard.getState(CardStateName.OriginalText).getSetCode());
|
||||||
|
affectedCard.getState(CardStateName.Original).setRarity(affectedCard.getState(CardStateName.OriginalText).getRarity());
|
||||||
|
|
||||||
// Enable this in case Volrath's original image is to be used
|
// Enable this in case Volrath's original image is to be used
|
||||||
affectedCard.getState(CardStateName.Original).setImageKey(affectedCard.getState(CardStateName.OriginalText).getImageKey());
|
affectedCard.getState(CardStateName.Original).setImageKey(affectedCard.getState(CardStateName.OriginalText).getImageKey());
|
||||||
|
|
||||||
@@ -572,8 +576,8 @@ public final class StaticAbilityContinuous {
|
|||||||
toughnessBonus = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, addT));
|
toughnessBonus = CardFactoryUtil.xCount(affectedCard, AbilityUtils.getSVar(stAb, addT));
|
||||||
se.addXMapValue(affectedCard, toughnessBonus);
|
se.addXMapValue(affectedCard, toughnessBonus);
|
||||||
}
|
}
|
||||||
affectedCard.addSemiPermanentPowerBoost(powerBonus);
|
affectedCard.addSemiPermanentPowerBoost(powerBonus, false);
|
||||||
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus);
|
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add keywords
|
// add keywords
|
||||||
|
|||||||
Reference in New Issue
Block a user