sending CField updates to a propper thread.

minor optimizations for the rest
This commit is contained in:
Maxmtg
2013-04-15 11:04:05 +00:00
parent 52cfa9657b
commit 99fd571e00
4 changed files with 13 additions and 15 deletions

View File

@@ -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);

View File

@@ -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;
@@ -176,10 +175,6 @@ public abstract class SpellAbility implements ISpellAbility {
this.payCosts = toPay;
}
public SpellAbility(final Card iSourceCard ) {
this(iSourceCard, null);
}
// Spell, and Ability, and other Ability objects override this method
/**
* <p>

View File

@@ -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,11 +82,9 @@ public class SpellPermanent extends Spell {
this.setDescription(this.getStackDescription());
if (this.getPayCosts().getTotalMana().countX() > 0) {
if (!this.getSourceCard().getSVar("X").equals("")) {
if (this.getPayCosts().getTotalMana().countX() > 0 && StringUtils.isNotBlank(getSourceCard().getSVar("X"))) {
this.setSVar("X", this.getSourceCard().getSVar("X"));
}
}
} // Spell_Permanent()

View File

@@ -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);
}
};