mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
added a method Card.isSplitCard() to shorten tests for split type.
This commit is contained in:
@@ -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?)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user