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")) {
|
} else if (property.startsWith("greatestRememberedCMC")) {
|
||||||
final List<Card> list = new ArrayList<Card>();
|
List<Card> list = new ArrayList<Card>();
|
||||||
for (final Object o : source.getRemembered()) {
|
for (final Object o : source.getRemembered()) {
|
||||||
if (o instanceof Card) {
|
if (o instanceof Card) {
|
||||||
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
list.add(Singletons.getModel().getGame().getCardState((Card) o));
|
||||||
@@ -7041,16 +7041,9 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (!list.contains(this)) {
|
if (!list.contains(this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (final Card crd : list) {
|
list = CardLists.getCardsWithHighestCMC(list);
|
||||||
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
|
if (!list.contains(this)) {
|
||||||
if (crd.getCMC(Card.SplitCMCMode.LeftSplitCMC) > this.getCMC() || crd.getCMC(Card.SplitCMCMode.RightSplitCMC) > this.getCMC()) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (crd.getCMC() > this.getCMC()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (property.startsWith("lowestCMC")) {
|
} else if (property.startsWith("lowestCMC")) {
|
||||||
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
final List<Card> list = Singletons.getModel().getGame().getCardsIn(ZoneType.Battlefield);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import forge.card.CardSplitType;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.ai.ComputerUtilCard;
|
import forge.game.ai.ComputerUtilCard;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -259,4 +260,42 @@ public class CardLists {
|
|||||||
res.add(c);
|
res.add(c);
|
||||||
return res;
|
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.CounterType;
|
||||||
import forge.GameEntity;
|
import forge.GameEntity;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
|
import forge.card.CardSplitType;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.ability.ApiType;
|
import forge.card.ability.ApiType;
|
||||||
@@ -1420,8 +1421,17 @@ public class CardFactoryUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final Card crd : list) {
|
for (final Card crd : list) {
|
||||||
if (crd.getCMC() > highest) {
|
if (crd.getRules() != null && crd.getRules().getSplitType() == CardSplitType.Split) {
|
||||||
highest = crd.getCMC();
|
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;
|
return highest;
|
||||||
|
|||||||
Reference in New Issue
Block a user