mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
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:
@@ -802,12 +802,12 @@ public class ChangeZoneEffect extends SpellAbilityEffect {
|
|||||||
for (int i = 0; i < changeNum && destination != null; i++) {
|
for (int i = 0; i < changeNum && destination != null; i++) {
|
||||||
if (sa.hasParam("DifferentNames")) {
|
if (sa.hasParam("DifferentNames")) {
|
||||||
for (Card c : chosenCards) {
|
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")) {
|
if (sa.hasParam("DifferentCMC")) {
|
||||||
for (Card c: chosenCards) {
|
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")) {
|
if (sa.hasParam("ShareLandType")) {
|
||||||
|
|||||||
@@ -5317,10 +5317,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
boolean shares;
|
boolean shares;
|
||||||
shares = getName().equals(c1.getName());
|
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.LeftSplit).getName());
|
||||||
shares |= c1.getName().equals(getState(CardStateName.RightSplit).getName());
|
shares |= c1.getName().equals(getState(CardStateName.RightSplit).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return shares;
|
return shares;
|
||||||
}
|
}
|
||||||
@@ -5335,6 +5335,34 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return shares;
|
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) {
|
public final boolean sharesCreatureTypeWith(final Card c1) {
|
||||||
if (c1 == null) {
|
if (c1 == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -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) {
|
public static final Predicate<Card> sharesColorWith(final Card color) {
|
||||||
return new Predicate<Card>() {
|
return new Predicate<Card>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user