feat(io): AsciiMap console renderer for MapView
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package thb.jeanluc.adventure.io.text;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.List;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AsciiMapTest {
|
||||
|
||||
@Test
|
||||
void rendersVisitedNameCurrentAndKnownStub() {
|
||||
RoomCell kitchen = new RoomCell("kitchen", "Kitchen", 0, 1, CellState.CURRENT);
|
||||
RoomCell hallway = new RoomCell("hallway", "Hallway", 0, 0, CellState.VISITED);
|
||||
RoomCell cellar = new RoomCell("cellar", "?", 1, 1, CellState.KNOWN);
|
||||
MapView v = new MapView(List.of(kitchen, hallway, cellar),
|
||||
List.of(new Connection(hallway, kitchen), new Connection(kitchen, cellar)));
|
||||
|
||||
String out = AsciiMap.render(v, true).plainText();
|
||||
|
||||
assertThat(out).contains("Kitchen");
|
||||
assertThat(out).contains("Hallway");
|
||||
assertThat(out).contains("?");
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyMapRendersPlaceholder() {
|
||||
String out = AsciiMap.render(new MapView(List.of(), List.of()), true).plainText();
|
||||
assertThat(out).containsIgnoringCase("no map");
|
||||
}
|
||||
|
||||
@Test
|
||||
void asciiModeUsesPlusFrames() {
|
||||
RoomCell only = new RoomCell("kitchen", "Kitchen", 0, 0, CellState.CURRENT);
|
||||
String out = AsciiMap.render(new MapView(List.of(only), List.of()), false).plainText();
|
||||
assertThat(out).contains("+").doesNotContain("┌");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user