Card: add sharesCMCWith use it for DifferentCMC in ChangeZoneEffect

also use sharesNameWith for DifferentNames in ChangeZoneEffect
that does fix Seasons Past with SplitCards
This commit is contained in:
Hanmac
2016-06-01 18:37:59 +00:00
parent cc89541131
commit db98f237c6
3 changed files with 50 additions and 4 deletions

View File

@@ -802,12 +802,12 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
for (int i = 0; i < changeNum && destination != null; i++) {
if (sa.hasParam("DifferentNames")) {
for (Card c : chosenCards) {
fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.nameEquals(c.getName())));
fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.sharesNameWith(c)));
}
}
if (sa.hasParam("DifferentCMC")) {
for (Card c: chosenCards) {
fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.hasCMC(c.getCMC())));
fetchList = CardLists.filter(fetchList, Predicates.not(CardPredicates.sharesCMCWith(c)));
}
}
if (sa.hasParam("ShareLandType")) {

View File

@@ -5317,10 +5317,10 @@ public class Card extends GameEntity implements Comparable<Card> {
boolean shares;
shares = getName().equals(c1.getName());
if (c1.isSplitCard()) {
if (isSplitCard() && c1.isSplitCard()) {
shares |= c1.getName().equals(getState(CardStateName.LeftSplit).getName());
shares |= c1.getName().equals(getState(CardStateName.RightSplit).getName());
}
}
return shares;
}
@@ -5335,6 +5335,34 @@ public class Card extends GameEntity implements Comparable<Card> {
return shares;
}
public final boolean sharesCMCWith(final Card c1) {
int x;
int x2 = -1;
int y = 0;
int y2 = -1;
if (isSplitCard() && getCurrentStateName() == CardStateName.Original) {
x = getState(CardStateName.LeftSplit).getManaCost().getCMC();
x2 = getState(CardStateName.RightSplit).getManaCost().getCMC();
} else {
x = getCMC();
}
if (c1.isSplitCard() && c1.getCurrentStateName() == CardStateName.Original) {
y = c1.getState(CardStateName.LeftSplit).getManaCost().getCMC();
y2 = c1.getState(CardStateName.RightSplit).getManaCost().getCMC();
if (isSplitCard() && getCurrentStateName() == CardStateName.Original) {
return x == y || x == y2 || x2 == y || x2 == y2;
} else {
return x == y || x == y2;
}
} else {
y = c1.getCMC();
return x == y || x2 == y;
}
}
public final boolean sharesCreatureTypeWith(final Card c1) {
if (c1 == null) {
return false;

View File

@@ -108,6 +108,24 @@ public final class CardPredicates {
};
}
public static final Predicate<Card> sharesNameWith(final Card name) {
return new Predicate<Card>() {
@Override
public boolean apply(Card c) {
return c.sharesNameWith(name);
}
};
}
public static final Predicate<Card> sharesCMCWith(final Card cmc) {
return new Predicate<Card>() {
@Override
public boolean apply(Card c) {
return c.sharesCMCWith(cmc);
}
};
}
public static final Predicate<Card> sharesColorWith(final Card color) {
return new Predicate<Card>() {
@Override