build ValidTgtsDesc via Lang (#9063)

* build ValidTgtsDesc via Lang

* use buildValidDesc for AuraSpells

* Add ValidTgtsDesc to GUI message
This commit is contained in:
Hans Mackowiak
2025-11-02 17:44:54 +01:00
committed by GitHub
parent e33ddee5bf
commit def3fa5d23
11 changed files with 125 additions and 106 deletions

View File

@@ -2,6 +2,8 @@ package forge.util;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import forge.card.CardType;
import forge.util.lang.*;
import org.apache.commons.lang3.StringUtils;
@@ -9,6 +11,7 @@ import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* Static library containing language-related utility methods.
@@ -216,4 +219,19 @@ public abstract class Lang {
}
return name.split(" ")[0];
}
public String buildValidDesc(List<String> valid, boolean multiple) {
return joinHomogenous(valid.stream().map(s -> formatValidDesc(s)).collect(Collectors.toList()), null, multiple ? "and/or" : "or");
}
public String formatValidDesc(String valid) {
List<String> commonStuff = List.of(
//list of common one word non-core type ValidTgts that should be lowercase in the target prompt
"Player", "Opponent", "Card", "Spell", "Permanent"
);
if (commonStuff.contains(valid) || CardType.isACardType(valid)) {
valid = valid.toLowerCase();
}
return valid;
}
}