mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +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();
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,17 +3140,21 @@ 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;
|
||||
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;
|
||||
if (updateViewImmediately) {
|
||||
currentState.getView().updateToughness(this);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setSemiPermanentPowerBoost(final int n) {
|
||||
if (semiPermanentPowerBoost == n) { return; }
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user