diff --git a/Mage.Sets/src/mage/cards/l/LongListOfTheEnts.java b/Mage.Sets/src/mage/cards/l/LongListOfTheEnts.java index 4e7d1676241..619a7356d7b 100644 --- a/Mage.Sets/src/mage/cards/l/LongListOfTheEnts.java +++ b/Mage.Sets/src/mage/cards/l/LongListOfTheEnts.java @@ -17,8 +17,9 @@ import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.game.stack.Spell; import mage.players.Player; +import mage.util.CardUtil; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -52,6 +53,11 @@ public final class LongListOfTheEnts extends CardImpl { public LongListOfTheEnts copy() { return new LongListOfTheEnts(this); } + + static String getKey(Game game, Ability source, int offset) { + return "EntList_" + source.getSourceId() + "_" + (offset + CardUtil.getActualSourceObjectZoneChangeCounter(game, source)); + } + } enum LongListOfTheEntsHint implements Hint { @@ -62,20 +68,20 @@ enum LongListOfTheEntsHint implements Hint { if (ability.getSourcePermanentIfItStillExists(game) == null) { return null; } - Set subTypes = LongListOfTheEntsEffect.getSubTypes(game, ability); - if (subTypes.isEmpty()) { + Set subTypes = (Set) game.getState().getValue(LongListOfTheEnts.getKey(game, ability, 0)); + if (subTypes == null || subTypes.isEmpty()) { return "No creature types have been noted yet."; } return subTypes .stream() .map(SubType::toString) .collect(Collectors.joining( - ", ", "Noted creature types: " + subTypes.size() + '(', ")" + ", ", "Noted creature types: " + subTypes.size() + " (", ")" )); } @Override - public Hint copy() { + public LongListOfTheEntsHint copy() { return this; } } @@ -103,30 +109,34 @@ class LongListOfTheEntsEffect extends OneShotEffect { if (player == null) { return false; } - Set chosenTypes = LongListOfTheEntsEffect - .getSubTypes(game, source) + ChoiceCreatureType choice = new ChoiceCreatureType(source.getSourceObject(game)); + Object existingEntList = game.getState().getValue(LongListOfTheEnts.getKey(game, source, 0)); + int offset; + Set newEntList; + if (existingEntList == null) { + offset = 1; // zcc is off-by-one due to still entering battlefield + newEntList = new LinkedHashSet<>(); + } else { + offset = 0; + newEntList = new LinkedHashSet<>((Set) existingEntList); + } + Set chosenTypes = newEntList .stream() .map(SubType::toString) .collect(Collectors.toSet()); - ChoiceCreatureType choice = new ChoiceCreatureType(source.getSourceObject(game)); choice.getChoices().removeIf(chosenTypes::contains); player.choose(Outcome.BoostCreature, choice, game); SubType subType = SubType.byDescription(choice.getChoice()); if (subType == null) { return false; } + game.informPlayers(player.getLogName() + " notes the creature type " + subType); + newEntList.add(subType); + game.getState().setValue(LongListOfTheEnts.getKey(game, source, offset), newEntList); game.addDelayedTriggeredAbility(new LongListOfTheEntsTriggeredAbility(subType), source); return true; } - static Set getSubTypes(Game game, Ability source) { - return (Set) game.getState().computeValueIfAbsent( - "EntList" - + source.getSourceId() - + source.getSourceObjectZoneChangeCounter(), - x -> new HashSet() - ); - } } class LongListOfTheEntsTriggeredAbility extends DelayedTriggeredAbility { diff --git a/Mage.Sets/src/mage/cards/s/SigardasSplendor.java b/Mage.Sets/src/mage/cards/s/SigardasSplendor.java index 8a4e4b1bea1..6e57256374c 100644 --- a/Mage.Sets/src/mage/cards/s/SigardasSplendor.java +++ b/Mage.Sets/src/mage/cards/s/SigardasSplendor.java @@ -17,6 +17,7 @@ import mage.filter.FilterSpell; import mage.filter.predicate.mageobject.ColorPredicate; import mage.game.Game; import mage.players.Player; +import mage.util.CardUtil; import java.util.UUID; @@ -55,9 +56,8 @@ public final class SigardasSplendor extends CardImpl { return new SigardasSplendor(this); } - static String getKey(Ability source, int offset) { - return "SigardasSplendor_" + source.getControllerId() + "_" + source.getSourceId() - + "_" + (source.getSourceObjectZoneChangeCounter() + offset); + static String getKey(Game game, Ability source, int offset) { + return "SigardasSplendor_" + source.getSourceId() + "_" + (offset + CardUtil.getActualSourceObjectZoneChangeCounter(game, source)); } } @@ -69,7 +69,7 @@ enum SigardasSplendorHint implements Hint { if (ability.getSourcePermanentIfItStillExists(game) == null) { return null; } - Object object = game.getState().getValue(SigardasSplendor.getKey(ability, 0)); + Object object = game.getState().getValue(SigardasSplendor.getKey(game, ability, 0)); return "Last noted life total: " + (object != null ? (Integer) object : "None"); } @@ -101,7 +101,8 @@ class SigardasSplendorNoteEffect extends OneShotEffect { if (player == null) { return false; } - game.getState().setValue(SigardasSplendor.getKey(source, -1), player.getLife()); + game.informPlayers(player.getLogName() + " notes their life total of " + player.getLife()); + game.getState().setValue(SigardasSplendor.getKey(game, source, 1), player.getLife()); return true; } } @@ -129,12 +130,13 @@ class SigardasSplendorDrawEffect extends OneShotEffect { if (player == null) { return false; } - String key = SigardasSplendor.getKey(source, 0); + String key = SigardasSplendor.getKey(game, source, 0); Object object = game.getState().getValue(key); int notedLife = object instanceof Integer ? (Integer) object : Integer.MIN_VALUE; if (player.getLife() >= notedLife) { player.drawCards(1, source, game); } + game.informPlayers(player.getLogName() + " notes their life total of " + player.getLife()); game.getState().setValue(key, player.getLife()); return true; }