added a method Card.isSplitCard() to shorten tests for split type.

This commit is contained in:
Maxmtg
2013-03-18 19:29:14 +00:00
parent 260f626ee1
commit 5bea8704c3
9 changed files with 31 additions and 35 deletions

View File

@@ -508,6 +508,10 @@ public class Card extends GameEntity implements Comparable<Card> {
return this.isFlipCard;
}
public final boolean isSplitCard() {
return cardRules != null && cardRules.getSplitType() == CardSplitType.Split;
}
/**
* Sets the flip card.
*
@@ -7021,7 +7025,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} else if (property.startsWith("greatestCMC")) {
final List<Card> list = CardLists.filter(Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield), Presets.CREATURES);
for (final Card crd : list) {
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
if (crd.isSplitCard()) {
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > this.getCMC()) {
return false;
}
@@ -7049,7 +7053,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
for (final Card crd : list) {
if (!crd.isLand() && !crd.isImmutable()) {
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
if (crd.isSplitCard()) {
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) < this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) < this.getCMC()) {
return false;
}
@@ -7119,7 +7123,7 @@ public class Card extends GameEntity implements Comparable<Card> {
y = this.getNetDefense();
} else if (property.startsWith("cmc")) {
rhs = property.substring(5);
if (getRules() != null && getRules().getSplitType() == CardSplitType.Split && getCurState() == CardCharacteristicName.Original) {
if (isSplitCard() && getCurState() == CardCharacteristicName.Original) {
y = getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC();
y2 = getState(CardCharacteristicName.RightSplit).getManaCost().getCMC();
} else {
@@ -9126,7 +9130,7 @@ public class Card extends GameEntity implements Comparable<Card> {
int requestedCMC = 0;
if (getRules() != null && getRules().getSplitType() == CardSplitType.Split) {
if (isSplitCard()) {
switch(mode) {
case CurrentSideCMC:
// TODO: test if this returns combined CMC for the full face (then get rid of CombinedCMC mode?)

View File

@@ -271,7 +271,7 @@ public class CardLists {
final List<Card> tiedForHighest = new ArrayList<Card>();
int highest = 0;
for (final Card crd : cardList) {
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
if (crd.isSplitCard()) {
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > highest) {
highest = crd.getCMC(Card.SplitCMCMode.LeftSplitCMC);
tiedForHighest.clear();

View File

@@ -240,7 +240,7 @@ public class CardFactory {
c.setState(CardCharacteristicName.Transformed);
c.setImageKey(ImageCache.getImageKey(cp, true));
}
else if (c.getRules().getSplitType() == CardSplitType.Split) {
else if (c.isSplitCard()) {
c.setState(CardCharacteristicName.LeftSplit);
c.setImageKey(originalPicture);
c.setCurSetCode(cp.getEdition());

View File

@@ -1421,7 +1421,7 @@ public class CardFactoryUtil {
}
}
for (final Card crd : list) {
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
if (crd.isSplitCard()) {
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > highest) {
highest = crd.getCMC(Card.SplitCMCMode.LeftSplitCMC);
}

View File

@@ -153,11 +153,9 @@ public class SpellAbilityRequirements {
final Card c = this.ability.getSourceCard();
// split cards transform back to full form if targeting is canceled
if (c.getRules() != null) {
if (c.getRules().getSplitType() == CardSplitType.Split) {
if (c.isSplitCard()) {
c.setState(CardCharacteristicName.Original);
}
}
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
// add back to where it came from
@@ -206,11 +204,9 @@ public class SpellAbilityRequirements {
final Card c = this.ability.getSourceCard();
// split cards transform back to full form if mana cost is not paid
if (c.getRules() != null) {
if (c.getRules().getSplitType() == CardSplitType.Split) {
if (c.isSplitCard()) {
c.setState(CardCharacteristicName.Original);
}
}
if (this.bCasting && !c.isCopiedSpell()) { // and not a copy
// add back to Previous Zone

View File

@@ -344,11 +344,9 @@ public class GameAction {
*/
public final Card moveTo(final Zone zoneTo, Card c) {
// if a split card is moved, convert it back to its full form before moving (unless moving to stack)
if (c.getRules() != null) {
if ((c.getRules().getSplitType() == CardSplitType.Split) && (zoneTo != game.getStackZone())) {
if (c.isSplitCard() && zoneTo != game.getStackZone()) {
c.setState(CardCharacteristicName.Original);
}
}
return moveTo(zoneTo, c, null);
}

View File

@@ -541,8 +541,7 @@ public class GameActionPlay {
private void setSplitCardState(final Card source, SpellAbility sa) {
// Split card support
if (source.getRules() != null) {
if (source.getRules().getSplitType() == CardSplitType.Split) {
if (source.isSplitCard()) {
List<SpellAbility> leftSplitAbilities = source.getState(CardCharacteristicName.LeftSplit).getSpellAbility();
List<SpellAbility> rightSplitAbilities = source.getState(CardCharacteristicName.RightSplit).getSpellAbility();
for (SpellAbility a : leftSplitAbilities) {
@@ -560,4 +559,3 @@ public class GameActionPlay {
}
}
}
}

View File

@@ -218,7 +218,7 @@ public class CardDetailPanel extends FPanel {
this.nameCostLabel.setText(card.getName());
} else {
String manaCost = card.getManaCost().toString();
if ( card.getRules() != null && card.getRules().getSplitType() == CardSplitType.Split && card.getCurState() == CardCharacteristicName.Original) {
if ( card.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
manaCost = card.getRules().getMainPart().getManaCost().toString() + " // " + card.getRules().getOtherPart().getManaCost().toString();
}
this.nameCostLabel.setText(card.getName() + " - " + manaCost);

View File

@@ -377,7 +377,7 @@ public class CardPanel extends JPanel implements CardContainer {
if (this.showCastingCost) {
if (this.cardWidth < 200) {
Card gameCard = this.getGameCard();
boolean showSplitMana = gameCard.getRules() != null && gameCard.getRules().getSplitType() == CardSplitType.Split && gameCard.getCurState() == CardCharacteristicName.Original;
boolean showSplitMana = gameCard.isSplitCard() && gameCard.getCurState() == CardCharacteristicName.Original;
if ( !showSplitMana ) {
drawManaCost(g, gameCard.getManaCost(), 0);
} else {