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 9ce939167c
commit fcf8083b7c
5 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package thb.jeanluc.adventure.command.impl;
import org.junit.jupiter.api.Test;
import thb.jeanluc.adventure.game.GameContext;
import thb.jeanluc.adventure.io.TestIO;
import thb.jeanluc.adventure.model.Direction;
import thb.jeanluc.adventure.model.Player;
import thb.jeanluc.adventure.model.Room;
import thb.jeanluc.adventure.model.World;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
class MapCommandTest {
@Test
void map_showsVisitedRoomAndKnownNeighbour() {
Room kitchen = new Room("kitchen", "Kitchen", "d");
Room hallway = new Room("hallway", "Hallway", "d");
kitchen.addExit(Direction.NORTH, hallway);
hallway.addExit(Direction.SOUTH, kitchen);
Map<String, Room> rooms = new LinkedHashMap<>();
rooms.put("kitchen", kitchen);
rooms.put("hallway", hallway);
World world = new World(rooms, Map.of(), Map.of(), "t", "w");
Player player = new Player(kitchen, 0); // visited = {kitchen}; hallway is a KNOWN stub
TestIO io = new TestIO();
GameContext ctx = new GameContext(world, player, io);
new MapCommand().execute(ctx, List.of());
String out = io.allOutput();
assertThat(out).contains("Kitchen"); // current room name appears on the map
assertThat(out).contains("?"); // unexplored neighbour stub
}
}