Card & CardPredicates: make hasCMC work with SplitCards

This commit is contained in:
Hanmac
2016-10-14 07:24:16 +00:00
parent f2b58e3093
commit a46d59d4b0
2 changed files with 18 additions and 5 deletions

View File

@@ -5453,6 +5453,19 @@ public class Card extends GameEntity implements Comparable<Card> {
return shares; return shares;
} }
public final boolean sharesCMCWith(final int n) {
//need to get GameState for Discarded Cards
final Card host = game.getCardState(this);
if (host.isSplitCard() && host.getCurrentStateName() == CardStateName.Original) {
int x = host.getCMC(SplitCMCMode.LeftSplitCMC);
int x2 = host.getCMC(SplitCMCMode.RightSplitCMC);
return x == n || x2 == n;
} else {
return host.getCMC() == n;
}
}
public final boolean sharesCMCWith(final Card c1) { public final boolean sharesCMCWith(final Card c1) {
int x; int x;
int x2 = -1; int x2 = -1;
@@ -5464,15 +5477,15 @@ public class Card extends GameEntity implements Comparable<Card> {
final Card other = game.getCardState(c1); final Card other = game.getCardState(c1);
if (host.isSplitCard() && host.getCurrentStateName() == CardStateName.Original) { if (host.isSplitCard() && host.getCurrentStateName() == CardStateName.Original) {
x = host.getState(CardStateName.LeftSplit).getManaCost().getCMC(); x = host.getCMC(SplitCMCMode.LeftSplitCMC);
x2 = host.getState(CardStateName.RightSplit).getManaCost().getCMC(); x2 = host.getCMC(SplitCMCMode.RightSplitCMC);
} else { } else {
x = host.getCMC(); x = host.getCMC();
} }
if (other.isSplitCard() && other.getCurrentStateName() == CardStateName.Original) { if (other.isSplitCard() && other.getCurrentStateName() == CardStateName.Original) {
y = other.getState(CardStateName.LeftSplit).getManaCost().getCMC(); y = other.getCMC(SplitCMCMode.LeftSplitCMC);
y2 = other.getState(CardStateName.RightSplit).getManaCost().getCMC(); y2 = other.getCMC(SplitCMCMode.RightSplitCMC);
if (host.isSplitCard() && host.getCurrentStateName() == CardStateName.Original) { if (host.isSplitCard() && host.getCurrentStateName() == CardStateName.Original) {
return x == y || x == y2 || x2 == y || x2 == y2; return x == y || x == y2 || x2 == y || x2 == y2;

View File

@@ -238,7 +238,7 @@ public final class CardPredicates {
return new Predicate<Card>() { return new Predicate<Card>() {
@Override @Override
public boolean apply(final Card c) { public boolean apply(final Card c) {
return c.getCMC() == cmc; return c.sharesCMCWith(cmc);
} }
}; };
} }