Transmutation Font - fixed game error on usage

This commit is contained in:
Oleg Agafonov 2024-05-10 15:28:45 +04:00
parent 36d54bc7a9
commit 095e481560

View file

@ -29,10 +29,7 @@ import mage.target.common.TargetCardInLibrary;
import mage.target.common.TargetSacrifice; import mage.target.common.TargetSacrifice;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
/** /**
@ -65,7 +62,7 @@ public final class TransmutationFont extends CardImpl {
class TransmutationFontEffect extends OneShotEffect { class TransmutationFontEffect extends OneShotEffect {
private static final Map<String, Supplier<Token>> map = new HashMap<>(); private static final Map<String, Supplier<Token>> map = new LinkedHashMap<>();
static { static {
map.put("Blood", BloodToken::new); map.put("Blood", BloodToken::new);
@ -95,9 +92,11 @@ class TransmutationFontEffect extends OneShotEffect {
} }
Choice choice = new ChoiceImpl(true); Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose a token to create"); choice.setMessage("Choose a token to create");
choice.setChoices(map.keySet()); choice.setChoices(new LinkedHashSet<>(map.keySet()));
player.choose(outcome, choice, game); player.choose(outcome, choice, game);
return map.get(choice.getChoice()).get().putOntoBattlefield(1, game, source); Supplier<Token> tokenType = map.getOrDefault(choice.getChoice(), null);
return tokenType != null
&& tokenType.get().putOntoBattlefield(1, game, source);
} }
} }