feat(game): push map to the IO each turn (GUI live update)

Game now derives the MapView from the world each turn; GameTest gains a
real World (the per-turn map push needs it).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 21:02:48 +02:00
parent fcf8083b7c
commit a0560a6ec5
2 changed files with 18 additions and 3 deletions

View File

@@ -10,6 +10,10 @@ 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.Map;
import static org.assertj.core.api.Assertions.assertThat;
@@ -24,7 +28,10 @@ class GameTest {
TestIO io = new TestIO()
.enqueue("go north")
.enqueue("quit");
GameContext ctx = new GameContext(null, player, io);
Map<String, Room> rooms = new LinkedHashMap<>();
rooms.put("kitchen", kitchen);
rooms.put("hallway", hallway);
GameContext ctx = new GameContext(new World(rooms, Map.of(), Map.of(), "t", "w"), player, io);
CommandRegistry registry = new CommandRegistry();
registry.register(new GoCommand(), "go");
@@ -42,9 +49,10 @@ class GameTest {
@Test
void run_unknownVerb_writesHint() {
Player player = new Player(new Room("r", "R", "d"), 0);
Room r = new Room("r", "R", "d");
Player player = new Player(r, 0);
TestIO io = new TestIO().enqueue("dance").enqueue("quit");
GameContext ctx = new GameContext(null, player, io);
GameContext ctx = new GameContext(new World(Map.of("r", r), Map.of(), Map.of(), "t", "w"), player, io);
CommandRegistry registry = new CommandRegistry();
QuitCommand quit = new QuitCommand();