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

View file

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

View file

@ -205,7 +205,9 @@ class GusthasScepterPutExiledCardsInOwnersGraveyardEffect extends OneShotEffect
@Override
public boolean apply(Game game, Ability 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;
}

View file

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