mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
- Made Scythe Specter work correctly when opponents discard cards tied for highest cmc.
- Made Heretic's Punishment work correctly with split cards
This commit is contained in:
@@ -7032,7 +7032,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("greatestRememberedCMC")) {
|
||||
final List<Card> list = new ArrayList<Card>();
|
||||
List<Card> list = new ArrayList<Card>();
|
||||
for (final Object o : source.getRemembered()) {
|
||||
if (o instanceof Card) {
|
||||
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||
@@ -7041,17 +7041,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
if (!list.contains(this)) {
|
||||
return false;
|
||||
}
|
||||
for (final Card crd : list) {
|
||||
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
|
||||
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > this.getCMC()) {
|
||||
list = CardLists.getCardsWithHighestCMC(list);
|
||||
if (!list.contains(this)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (crd.getCMC() > this.getCMC()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (property.startsWith("lowestCMC")) {
|
||||
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||
for (final Card crd : list) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
@@ -259,4 +260,42 @@ public class CardLists {
|
||||
res.add(c);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a List<Card> cardList, return a List<Card> that are tied for having the highest CMC.
|
||||
*
|
||||
* @param cardList the Card List to be filtered.
|
||||
* @return CardList the list of Cards sharing the highest CMC.
|
||||
*/
|
||||
public static List<Card> getCardsWithHighestCMC(Iterable<Card> cardList) {
|
||||
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.getCMC(Card.SplitCMCMode.LeftSplitCMC) > highest) {
|
||||
highest = crd.getCMC(Card.SplitCMCMode.LeftSplitCMC);
|
||||
tiedForHighest.clear();
|
||||
tiedForHighest.add(crd);
|
||||
} else if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) == highest && !tiedForHighest.contains(crd)) {
|
||||
tiedForHighest.add(crd);
|
||||
}
|
||||
if (crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > highest) {
|
||||
highest = crd.getCMC(Card.SplitCMCMode.RightSplitCMC);
|
||||
tiedForHighest.clear();
|
||||
tiedForHighest.add(crd);
|
||||
} else if (crd.getCMC(Card.SplitCMCMode.RightSplitCMC) == highest && !tiedForHighest.contains(crd)) {
|
||||
tiedForHighest.add(crd);
|
||||
}
|
||||
} else {
|
||||
if (crd.getCMC() > highest) {
|
||||
highest = crd.getCMC();
|
||||
tiedForHighest.clear();
|
||||
tiedForHighest.add(crd);
|
||||
} else if (crd.getCMC() == highest && !tiedForHighest.contains(crd)) {
|
||||
tiedForHighest.add(crd);
|
||||
}
|
||||
}
|
||||
}
|
||||
return tiedForHighest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import forge.Constant;
|
||||
import forge.CounterType;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardSplitType;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
@@ -1420,10 +1421,19 @@ public class CardFactoryUtil {
|
||||
}
|
||||
}
|
||||
for (final Card crd : list) {
|
||||
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
|
||||
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > highest) {
|
||||
highest = crd.getCMC(Card.SplitCMCMode.LeftSplitCMC);
|
||||
}
|
||||
if (crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > highest) {
|
||||
highest = crd.getCMC(Card.SplitCMCMode.RightSplitCMC);
|
||||
}
|
||||
} else {
|
||||
if (crd.getCMC() > highest) {
|
||||
highest = crd.getCMC();
|
||||
}
|
||||
}
|
||||
}
|
||||
return highest;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user