feat(io,command): map command + GameIO setMap/showMap, console ASCII

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 21:02:17 +02:00
parent a846297abe
commit 7605b724b6
5 changed files with 87 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
package thb.jeanluc.adventure.io;
import thb.jeanluc.adventure.io.text.AsciiMap;
import thb.jeanluc.adventure.io.text.Hud;
import thb.jeanluc.adventure.io.text.MapView;
import thb.jeanluc.adventure.io.text.RoomView;
import thb.jeanluc.adventure.io.text.Span;
import thb.jeanluc.adventure.io.text.Style;
@@ -100,6 +102,11 @@ public class ConsoleIO implements GameIO {
out.println(paint(Style.DIM, line));
}
@Override
public void showMap(MapView view) {
print(AsciiMap.render(view, glyphs != GlyphMode.ASCII));
}
private String section(String label, List<String> xs, Style st) {
StringBuilder sb = new StringBuilder(" ").append(paint(Style.DIM, label)).append(" ");
for (int i = 0; i < xs.size(); i++) {

View File

@@ -1,6 +1,8 @@
package thb.jeanluc.adventure.io;
import thb.jeanluc.adventure.io.text.AsciiMap;
import thb.jeanluc.adventure.io.text.Hud;
import thb.jeanluc.adventure.io.text.MapView;
import thb.jeanluc.adventure.io.text.Renderings;
import thb.jeanluc.adventure.io.text.RoomView;
import thb.jeanluc.adventure.io.text.StyledText;
@@ -32,4 +34,14 @@ public interface GameIO {
default void setHud(Hud hud) {
// no-op
}
/** Per-turn push of the current map. GUI repaints its panel; console ignores. */
default void setMap(MapView view) {
// no-op
}
/** On-demand map (the 'map' command). Default renders ASCII (Unicode frames). */
default void showMap(MapView view) {
print(AsciiMap.render(view, true));
}
}