Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.function.Function;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -338,6 +340,47 @@ private ConsoleCommandInterpreter() {
System.out.println("POI Names - Types\n" + String.join("\n", poiNames));
return "POI lists dumped to stdout.";
});
registerCommand(new String[]{"reveal"}, s -> {
WorldSave save = WorldSave.getCurrentSave();
if (save == null || save.getWorld() == null) {
return "No world loaded.";
}
if (s.length < 1) {
return "Please specify at least one PointOfInterest type (e.g. \"reveal cave\", \"reveal dungeon\", \"reveal city\", \"reveal capital\").";
}
HashSet<String> types = new HashSet<>();
for (String type : s) {
String normalized = type.toLowerCase();
if (normalized.endsWith("ies")) {
normalized = normalized.substring(0, normalized.length() - 3) + "y";
} else if (normalized.endsWith("s") && normalized.length() > 1) {
normalized = normalized.substring(0, normalized.length() - 1);
}
if (!normalized.isEmpty()) {
types.add(normalized);
}
}
if (types.isEmpty()) {
return "Please specify at least one PointOfInterest type (e.g. \"reveal cave\", \"reveal dungeon\", \"reveal city\", \"reveal capital\").";
}
int revealed = 0;
for (PointOfInterest poi : save.getWorld().getAllPointOfInterest()) {
PointOfInterestData data = poi.getData();
if (data == null || data.type == null) {
continue;
}
if (!types.contains(data.type.toLowerCase())) {
continue;
}
if (!save.getPointOfInterestChanges(poi.getID()).isVisited()) {
save.getPointOfInterestChanges(poi.getID()).visit();
revealed++;
}
}
ArrayList<String> sortedTypes = new ArrayList<>(types);
Collections.sort(sortedTypes);
return "Revealed " + revealed + " " + String.join("/", sortedTypes) + " names on the map.";
});
registerCommand(new String[]{"setColorID"}, s -> {
if (s.length < 1)
return "Please specify color ID: Valid choices: B, G, R, U, W, C. Example:\n\"setColorID G\"";
Expand Down