Keen-Eyed Curator - fixed game error on usage in deck (also fixed Gustha's Scepter, Eater of Virtue, Death-Mask Duplicant);

This commit is contained in:
Oleg Agafonov 2024-08-18 14:30:17 +04:00
parent a827a93cf2
commit 141a4e5437
5 changed files with 27 additions and 26 deletions

View file

@ -30,6 +30,7 @@ import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -91,11 +92,9 @@ public final class DeathMaskDuplicant extends CardImpl {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)); ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)));
if (exileId != null if (exileZone != null && !exileZone.isEmpty()) {
&& game.getState().getExile().getExileZone(exileId) != null for (UUID cardId : exileZone) {
&& !game.getState().getExile().getExileZone(exileId).isEmpty()) {
for (UUID cardId : game.getState().getExile().getExileZone(exileId)) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null && card.isCreature(game)) { if (card != null && card.isCreature(game)) {
for (Ability ability : card.getAbilities(game)) { for (Ability ability : card.getAbilities(game)) {

View file

@ -40,6 +40,7 @@ import mage.constants.SubLayer;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -135,10 +136,9 @@ class EaterOfVirtueGainAbilityAttachedEffect extends ContinuousEffectImpl {
&& eaterOfVirtue.getAttachedTo() != null) { && eaterOfVirtue.getAttachedTo() != null) {
Permanent permanent = game.getPermanent(eaterOfVirtue.getAttachedTo()); Permanent permanent = game.getPermanent(eaterOfVirtue.getAttachedTo());
if (permanent != null) { if (permanent != null) {
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + "cards exiled by Eater of Virtue", game); ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(source.getSourceId().toString() + "cards exiled by Eater of Virtue", game));
if (game.getState().getExile().getExileZone(exileId) != null if (exileZone != null && !exileZone.isEmpty()) {
&& game.getState().getExile().getExileZone(exileId).size() > 0) { Set<Card> cardsInExile = exileZone.getCards(game);
Set<Card> cardsInExile = game.getState().getExile().getExileZone(exileId).getCards(game);
for (Card card : cardsInExile) { for (Card card : cardsInExile) {
for (Ability a : card.getAbilities()) { for (Ability a : card.getAbilities()) {
if (a instanceof FlyingAbility) { if (a instanceof FlyingAbility) {

View file

@ -205,7 +205,9 @@ class GusthasScepterPutExiledCardsInOwnersGraveyardEffect extends OneShotEffect
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source)); ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
exileZone.getCards(game).stream().forEach(card -> card.moveToZone(Zone.GRAVEYARD, source, game, false)); if (exileZone != null) {
exileZone.getCards(game).forEach(card -> card.moveToZone(Zone.GRAVEYARD, source, game, false));
}
return true; return true;
} }

View file

@ -17,10 +17,12 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.SubType; import mage.constants.SubType;
import mage.game.ExileZone;
import mage.game.Game; import mage.game.Game;
import mage.target.common.TargetCardInGraveyard; import mage.target.common.TargetCardInGraveyard;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -72,10 +74,8 @@ enum KeenEyedCuratorCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return game ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
.getExile() return exileZone != null && exileZone.getCards(game)
.getExileZone(CardUtil.getExileZoneId(game, source))
.getCards(game)
.stream() .stream()
.map(card -> card.getCardType(game)) .map(card -> card.getCardType(game))
.flatMap(Collection::stream) .flatMap(Collection::stream)
@ -89,17 +89,17 @@ enum KeenEyedCuratorHint implements Hint {
@Override @Override
public String getText(Game game, Ability ability) { public String getText(Game game, Ability ability) {
List<String> types = game List<String> types = new ArrayList<>();
.getExile() ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, ability));
.getExileZone(CardUtil.getExileZoneId(game, ability)) if (exileZone != null) {
.getCards(game) types = exileZone.getCards(game).stream()
.stream() .map(card -> card.getCardType(game))
.map(card -> card.getCardType(game)) .flatMap(Collection::stream)
.flatMap(Collection::stream) .distinct()
.distinct() .map(CardType::toString)
.map(CardType::toString) .sorted()
.sorted() .collect(Collectors.toList());
.collect(Collectors.toList()); }
return "Card types exiled: " + types.size() return "Card types exiled: " + types.size()
+ (types.size() > 0 ? " (" + String.join(", ", types) + ')' : ""); + (types.size() > 0 ? " (" + String.join(", ", types) + ')' : "");
} }

View file

@ -1495,7 +1495,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
*/ */
public void assertExileZoneCount(String exileZoneName, int count) throws AssertionError { public void assertExileZoneCount(String exileZoneName, int count) throws AssertionError {
ExileZone exileZone = currentGame.getExile().getExileZone(CardUtil.getExileZoneId(exileZoneName, currentGame)); ExileZone exileZone = currentGame.getExile().getExileZone(CardUtil.getExileZoneId(exileZoneName, currentGame));
int actualCount = exileZone.getCards(currentGame).size(); int actualCount = exileZone == null ? 0 : exileZone.getCards(currentGame).size();
Assert.assertEquals("(Exile \"" + exileZoneName + "\") Card counts are not equal.", count, actualCount); Assert.assertEquals("(Exile \"" + exileZoneName + "\") Card counts are not equal.", count, actualCount);
} }