mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -08:00
cleanup usage of SubType from string
This commit is contained in:
parent
4f2f566b32
commit
66716a4314
4 changed files with 17 additions and 10 deletions
|
|
@ -4,16 +4,14 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.keyword.FlashbackAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.cards.*;
|
||||
import mage.choices.ChoiceCreatureType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
|
@ -72,9 +70,15 @@ class ForTheAncestorsEffect extends OneShotEffect {
|
|||
}
|
||||
ChoiceCreatureType choice = new ChoiceCreatureType();
|
||||
player.choose(outcome, choice, game);
|
||||
SubType subType = SubType.fromString(choice.getChoice());
|
||||
FilterCard filter = new FilterCard(subType + " cards");
|
||||
SubType subType = SubType.byDescription(choice.getChoice());
|
||||
FilterCard filter;
|
||||
if (subType != null) {
|
||||
filter = new FilterCard(choice.getChoice() + " cards");
|
||||
filter.add(subType.getPredicate());
|
||||
} else {
|
||||
filter = new FilterCard();
|
||||
filter.add((Predicate<Card>) (input, game1) -> false);
|
||||
}
|
||||
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 6));
|
||||
TargetCard target = new TargetCardInHand(0, Integer.MAX_VALUE, filter);
|
||||
player.choose(outcome, cards, target, source, game);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class LeoriSparktouchedHunterEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
|
||||
SubType subType = SubType.fromString(choice.getChoice());
|
||||
SubType subType = SubType.byDescription(choice.getChoice());
|
||||
if (subType == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class LongListOfTheEntsEffect extends OneShotEffect {
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
Set<String> chosenTypes = this
|
||||
Set<String> chosenTypes = LongListOfTheEntsEffect
|
||||
.getSubTypes(game, source)
|
||||
.stream()
|
||||
.map(SubType::toString)
|
||||
|
|
@ -111,7 +111,7 @@ class LongListOfTheEntsEffect extends OneShotEffect {
|
|||
ChoiceCreatureType choice = new ChoiceCreatureType(source.getSourceObject(game));
|
||||
choice.getChoices().removeIf(chosenTypes::contains);
|
||||
player.choose(Outcome.BoostCreature, choice, game);
|
||||
SubType subType = SubType.fromString(choice.getChoice());
|
||||
SubType subType = SubType.byDescription(choice.getChoice());
|
||||
if (subType == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,6 +600,9 @@ public enum SubType {
|
|||
return customSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use in test framework only, use SubType.byDescription instead for card logic
|
||||
*/
|
||||
public static SubType fromString(String value) {
|
||||
for (SubType st : SubType.values()) {
|
||||
if (st.toString().equals(value)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue