From 99fd571e0087a3184a5bc98a72bf7ecf018e4339 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Mon, 15 Apr 2013 11:04:05 +0000 Subject: [PATCH] sending CField updates to a propper thread. minor optimizations for the rest --- src/main/java/forge/card/cost/Cost.java | 1 + .../java/forge/card/spellability/SpellAbility.java | 11 +++-------- .../java/forge/card/spellability/SpellPermanent.java | 8 ++++---- .../java/forge/gui/match/nonsingleton/CField.java | 8 +++++--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/java/forge/card/cost/Cost.java b/src/main/java/forge/card/cost/Cost.java index 7b7ceae9d0a..3037888133a 100644 --- a/src/main/java/forge/card/cost/Cost.java +++ b/src/main/java/forge/card/cost/Cost.java @@ -376,6 +376,7 @@ public class Cost { public final Cost copyWithNoMana() { Cost toRet = new Cost(0); + toRet.isAbility = this.isAbility; for(CostPart cp : this.costParts) { if (!(cp instanceof CostPartMana)) toRet.costParts.add(cp); diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java index 4bc94cdef72..f55fcc2384f 100644 --- a/src/main/java/forge/card/spellability/SpellAbility.java +++ b/src/main/java/forge/card/spellability/SpellAbility.java @@ -59,7 +59,6 @@ public abstract class SpellAbility implements ISpellAbility { private String type = "Intrinsic"; // set to Intrinsic by default - private Card targetCard; private Card sourceCard; private Card originalHost = null; @@ -78,12 +77,12 @@ public abstract class SpellAbility implements ISpellAbility { private boolean cycling = false; private boolean delve = false; - /** The pay costs. */ - private Cost payCosts = null; - + private Card targetCard; /** The chosen target. */ private Target chosenTarget = null; + /** The pay costs. */ + private Cost payCosts = null; private SpellAbilityRestriction restrictions = new SpellAbilityRestriction(); private SpellAbilityCondition conditions = new SpellAbilityCondition(); private AbilitySub subAbility = null; @@ -175,10 +174,6 @@ public abstract class SpellAbility implements ISpellAbility { this.sourceCard = iSourceCard; this.payCosts = toPay; } - - public SpellAbility(final Card iSourceCard ) { - this(iSourceCard, null); - } // Spell, and Ability, and other Ability objects override this method /** diff --git a/src/main/java/forge/card/spellability/SpellPermanent.java b/src/main/java/forge/card/spellability/SpellPermanent.java index fa442a5d8b7..05320ce675d 100644 --- a/src/main/java/forge/card/spellability/SpellPermanent.java +++ b/src/main/java/forge/card/spellability/SpellPermanent.java @@ -22,6 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.commons.lang3.StringUtils; + import com.google.common.collect.Iterables; import forge.Card; @@ -80,10 +82,8 @@ public class SpellPermanent extends Spell { this.setDescription(this.getStackDescription()); - if (this.getPayCosts().getTotalMana().countX() > 0) { - if (!this.getSourceCard().getSVar("X").equals("")) { - this.setSVar("X", this.getSourceCard().getSVar("X")); - } + if (this.getPayCosts().getTotalMana().countX() > 0 && StringUtils.isNotBlank(getSourceCard().getSVar("X"))) { + this.setSVar("X", this.getSourceCard().getSVar("X")); } } // Spell_Permanent() diff --git a/src/main/java/forge/gui/match/nonsingleton/CField.java b/src/main/java/forge/gui/match/nonsingleton/CField.java index 4ff05c1f474..ca602182919 100644 --- a/src/main/java/forge/gui/match/nonsingleton/CField.java +++ b/src/main/java/forge/gui/match/nonsingleton/CField.java @@ -129,15 +129,17 @@ public class CField implements ICDoc { private final Observer observerZones = new Observer() { @Override public void update(final Observable a, final Object b) { - CField.this.view.updateZones(CField.this.player); + FThreads.invokeInEdtNowOrLater(updateZonesRunnable); } }; - + private final Runnable updateZonesRunnable = new Runnable() { @Override public void run() { CField.this.view.updateZones(CField.this.player); } }; + private final Runnable updateDetailsRunnable = new Runnable() { @Override public void run() { CField.this.view.updateDetails(CField.this.player); } }; + // Life total, poison total, and keywords, attached directly to Player. private final Observer observerDetails = new Observer() { @Override public void update(final Observable a, final Object b) { - CField.this.view.updateDetails(CField.this.player); + FThreads.invokeInEdtNowOrLater(updateDetailsRunnable); } };