- 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:
Agetian
2017-08-28 14:06:28 +00:00
parent c180343853
commit 04f24faf32
6 changed files with 40 additions and 18 deletions

View File

@@ -843,6 +843,12 @@ public class GameAction {
final Map<String, Object> runParams = Maps.newHashMap();
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()) {
game.fireEvent(new GameEventCardStatsChanged(affectedCards));
}

View File

@@ -1003,8 +1003,9 @@ public class StaticEffect {
if (addT.startsWith("AffectedX")) {
toughnessBonus = getXMapValue(affectedCard);
}
affectedCard.addSemiPermanentPowerBoost(powerBonus * -1);
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus * -1);
// the view is updated in GameAction#checkStaticAbilities to avoid flickering
affectedCard.addSemiPermanentPowerBoost(powerBonus * -1, false);
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus * -1, false);
// remove keywords
// TODO regular keywords currently don't try to use keyword multiplier
@@ -1046,7 +1047,8 @@ public class StaticEffect {
// remove Types
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

View File

@@ -63,8 +63,8 @@ public class StaticEffects {
/**
* Add a static effect to the list of static effects.
*
* @param staticEffect
* a {@link StaticEffect}.
* @param staticAbility
* a {@link StaticAbility}.
*/
public final StaticEffect getStaticEffect(final StaticAbility staticAbility) {
final StaticEffect currentEffect = staticEffects.get(staticAbility);

View File

@@ -52,7 +52,7 @@ public class PumpEffect extends SpellAbilityEffect {
applyTo.addTempPowerBoost(a);
applyTo.addTempToughnessBoost(d);
applyTo.addChangedCardKeywords(kws, Lists.<String>newArrayList(), false, timestamp);
if (redrawPT) { applyTo.updatePowerToughnessView(); }
if (redrawPT) { applyTo.updatePowerToughnessForView(); }
if (sa.hasParam("LeaveBattlefield")) {
addLeaveBattlefieldReplacement(applyTo, sa, sa.getParam("LeaveBattlefield"));
@@ -76,7 +76,7 @@ public class PumpEffect extends SpellAbilityEffect {
if (kw.startsWith("HIDDEN")) {
applyTo.removeHiddenExtrinsicKeyword(kw);
if (redrawPT) {
applyTo.updatePowerToughnessView();
applyTo.updatePowerToughnessForView();
}
}
}

View File

@@ -456,11 +456,22 @@ public class Card extends GameEntity implements Comparable<Card> {
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() {
view.getCurrentState().updateKeywords(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) {
preFaceDownState = preCharacteristic;
}
@@ -3129,16 +3140,20 @@ public class Card extends GameEntity implements Comparable<Card> {
return semiPermanentToughnessBoost;
}
public final void addSemiPermanentPowerBoost(final int n) {
public final void addSemiPermanentPowerBoost(final int n, final boolean updateViewImmediately) {
if (n == 0) { return; }
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; }
semiPermanentToughnessBoost += n;
currentState.getView().updateToughness(this);
if (updateViewImmediately) {
currentState.getView().updateToughness(this);
}
}
public final void setSemiPermanentPowerBoost(final int n) {
@@ -3153,11 +3168,6 @@ public class Card extends GameEntity implements Comparable<Card> {
currentState.getView().updateToughness(this);
}
public final void updatePowerToughnessView() {
currentState.getView().updatePower(this);
currentState.getView().updateToughness(this);
}
public final boolean isUntapped() {
return !tapped;
}

View File

@@ -496,6 +496,10 @@ public final class StaticAbilityContinuous {
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
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));
se.addXMapValue(affectedCard, toughnessBonus);
}
affectedCard.addSemiPermanentPowerBoost(powerBonus);
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus);
affectedCard.addSemiPermanentPowerBoost(powerBonus, false);
affectedCard.addSemiPermanentToughnessBoost(toughnessBonus, false);
}
// add keywords