mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-11 16:26:22 +00:00
build ValidTgtsDesc via Lang (#9063)
* build ValidTgtsDesc via Lang * use buildValidDesc for AuraSpells * Add ValidTgtsDesc to GUI message
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user