|
|
@@ -6,7 +6,6 @@ import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
@@ -20,10 +19,11 @@ import lombok.experimental.FieldDefaults;
|
|
|
|
|
|
@AllArgsConstructor @Data
|
|
|
@FieldDefaults(level=AccessLevel.PRIVATE)
|
|
|
-public class DDSkillPrototype {
|
|
|
+class DDSkillPrototype {
|
|
|
final String name;
|
|
|
final boolean requiresTraining;
|
|
|
String ability = "";
|
|
|
+ boolean fromWildcardSkill = false;
|
|
|
|
|
|
private static final Map<String, DDSkillPrototype> prototypes;
|
|
|
|
|
|
@@ -42,20 +42,26 @@ public class DDSkillPrototype {
|
|
|
}
|
|
|
|
|
|
public DDSkillPrototype(String name) {
|
|
|
- DDSkillPrototype base = getPrototype(name).get();
|
|
|
+ DDSkillPrototype base = getPrototype(name);
|
|
|
this.name = name;
|
|
|
this.requiresTraining = base.requiresTraining;
|
|
|
this.ability = base.ability;
|
|
|
+ this.fromWildcardSkill = base.fromWildcardSkill;
|
|
|
}
|
|
|
|
|
|
- public static Optional<DDSkillPrototype> getPrototype(String name) {
|
|
|
+ public boolean isWildcardSkill() {
|
|
|
+ return name.contains("(*)");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static DDSkillPrototype getPrototype(String name) {
|
|
|
if (name.contains("(")) {
|
|
|
DDSkillPrototype proto = prototypes.get(name.replaceFirst("\\(.*\\)", "(*)"));
|
|
|
- if ( proto == null ) return Optional.empty();
|
|
|
- return Optional.of(new DDSkillPrototype(name, proto.requiresTraining, proto.ability));
|
|
|
- } else {
|
|
|
- return Optional.ofNullable(prototypes.get(name));
|
|
|
+ if (proto != null) { return new DDSkillPrototype(name, proto.requiresTraining, proto.ability, true); }
|
|
|
+ }
|
|
|
+ if (prototypes.containsKey(name)) {
|
|
|
+ return prototypes.get(name);
|
|
|
}
|
|
|
+ throw new IllegalStateException("Unknown skill '" + name + "'");
|
|
|
}
|
|
|
|
|
|
public static Stream<DDSkillPrototype> all() {
|
|
|
@@ -64,5 +70,5 @@ public class DDSkillPrototype {
|
|
|
|
|
|
public static Stream<DDSkillPrototype> untrained() {
|
|
|
return prototypes.values().stream().filter(p -> !p.requiresTraining && !p.getName().contains("(*)"));
|
|
|
- }
|
|
|
+ }
|
|
|
}
|