feat: conditional NPC dialogue

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 21:55:15 +02:00
parent c9c019cea1
commit 268c24d4e3
5 changed files with 76 additions and 3 deletions

View File

@@ -113,10 +113,15 @@ public class ReferenceResolver {
*/
public void resolveNpcs(List<NpcDto> npcDtos) {
for (NpcDto dto : npcDtos) {
Npc npc = npcs.get(dto.id());
if (dto.dialogue() != null) {
for (DialogueLineDto dl : dto.dialogue()) {
npc.addDialogue(new DialogueLine(ConditionDto.toModelList(dl.when()), dl.text()));
}
}
if (dto.reactions() == null) {
continue;
}
Npc npc = npcs.get(dto.id());
for (ReactionDto r : dto.reactions()) {
if (r.onReceive() == null) {
throw new WorldLoadException(

View File

@@ -10,12 +10,18 @@ import java.util.List;
* @param description examine description
* @param greeting text the NPC says on {@code talk}
* @param reactions list of trigger/response definitions; may be null
* @param dialogue optional condition-gated dialogue lines; may be null
*/
public record NpcDto(
String id,
String name,
String description,
String greeting,
List<ReactionDto> reactions
List<ReactionDto> reactions,
List<DialogueLineDto> dialogue
) {
/** Backward-compatible constructor without dialogue. */
public NpcDto(String id, String name, String description, String greeting, List<ReactionDto> reactions) {
this(id, name, description, greeting, reactions, null);
}
}