feat: NPC reactions gated by conditions, applying effects

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

View File

@@ -155,6 +155,8 @@ public class ReferenceResolver {
.consumes(consumes)
.gives(gives)
.response(r.response())
.requires(ConditionDto.toModelList(r.requires()))
.effects(EffectDto.toModelList(r.effects()))
.build();
npc.putReaction(r.onReceive(), reaction);
}

View File

@@ -1,5 +1,7 @@
package thb.jeanluc.adventure.loader.dto;
import java.util.List;
/**
* YAML representation of a single NPC reaction.
*
@@ -7,11 +9,19 @@ package thb.jeanluc.adventure.loader.dto;
* @param response text the NPC says after the exchange
* @param gives id of the item handed back; nullable
* @param consumes id of the item taken from the player; nullable
* @param requires conditions that must hold; nullable
* @param effects effects applied after a successful exchange; nullable
*/
public record ReactionDto(
String onReceive,
String response,
String gives,
String consumes
String consumes,
List<ConditionDto> requires,
List<EffectDto> effects
) {
/** Backward-compatible constructor without requires/effects. */
public ReactionDto(String onReceive, String response, String gives, String consumes) {
this(onReceive, response, gives, consumes, null, null);
}
}