- 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:
moomarc
2013-03-18 17:18:58 +00:00
parent 5742264443
commit 260f626ee1
3 changed files with 55 additions and 13 deletions

View File

@@ -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,16 +7041,9 @@ 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()) {
return false;
}
} else {
if (crd.getCMC() > this.getCMC()) {
return false;
}
}
list = CardLists.getCardsWithHighestCMC(list);
if (!list.contains(this)) {
return false;
}
} else if (property.startsWith("lowestCMC")) {
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);

View File

@@ -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;
}
}

View File

@@ -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,8 +1421,17 @@ public class CardFactoryUtil {
}
}
for (final Card crd : list) {
if (crd.getCMC() > highest) {
highest = crd.getCMC();
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;