mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Long List of the Ents, Sigarda's Splendor - fixed card hint and improved logic (#11568)
This commit is contained in:
parent
9ad456239e
commit
3bc9999207
2 changed files with 34 additions and 22 deletions
|
|
@ -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<SubType> subTypes = LongListOfTheEntsEffect.getSubTypes(game, ability);
|
||||
if (subTypes.isEmpty()) {
|
||||
Set<SubType> subTypes = (Set<SubType>) 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<String> 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<SubType> 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<SubType>) existingEntList);
|
||||
}
|
||||
Set<String> 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<SubType> getSubTypes(Game game, Ability source) {
|
||||
return (Set<SubType>) game.getState().computeValueIfAbsent(
|
||||
"EntList"
|
||||
+ source.getSourceId()
|
||||
+ source.getSourceObjectZoneChangeCounter(),
|
||||
x -> new HashSet<SubType>()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class LongListOfTheEntsTriggeredAbility extends DelayedTriggeredAbility {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue