feat: state-dependent room descriptions (LookCommand resolution)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package thb.jeanluc.adventure.command.impl;
|
||||
|
||||
import thb.jeanluc.adventure.command.Command;
|
||||
import thb.jeanluc.adventure.game.Conditions;
|
||||
import thb.jeanluc.adventure.game.GameContext;
|
||||
import thb.jeanluc.adventure.io.text.RoomView;
|
||||
import thb.jeanluc.adventure.model.DescriptionState;
|
||||
import thb.jeanluc.adventure.model.Direction;
|
||||
import thb.jeanluc.adventure.model.Npc;
|
||||
import thb.jeanluc.adventure.model.Room;
|
||||
@@ -22,7 +24,14 @@ public class LookCommand implements Command {
|
||||
List<String> items = room.getItems().values().stream().map(Item::getName).toList();
|
||||
List<String> npcs = room.getNpcs().values().stream().map(Npc::getName).toList();
|
||||
List<String> exits = room.getExits().keySet().stream().map(Direction::getLabel).toList();
|
||||
ctx.getIo().showRoom(new RoomView(room.getName(), room.getDescription(), items, npcs, exits));
|
||||
String description = room.getDescription();
|
||||
for (DescriptionState ds : room.getDescriptionStates()) {
|
||||
if (Conditions.all(ds.when(), ctx)) {
|
||||
description = ds.text();
|
||||
break;
|
||||
}
|
||||
}
|
||||
ctx.getIo().showRoom(new RoomView(room.getName(), description, items, npcs, exits));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user