diff --git a/forge-gui-mobile/src/forge/adventure/stage/ConsoleCommandInterpreter.java b/forge-gui-mobile/src/forge/adventure/stage/ConsoleCommandInterpreter.java index af094e54675..df52738d490 100644 --- a/forge-gui-mobile/src/forge/adventure/stage/ConsoleCommandInterpreter.java +++ b/forge-gui-mobile/src/forge/adventure/stage/ConsoleCommandInterpreter.java @@ -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; @@ -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 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 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\"";