feat(game): Quest model, QuestLog, START_QUEST effect

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 22:25:58 +02:00
parent eeee609c26
commit dd16d1326b
8 changed files with 114 additions and 1 deletions

View File

@@ -53,4 +53,11 @@ class EffectsTest {
Effects.apply(new Effect(Effect.Type.SAY, "boo"), ctx);
assertThat(((TestIO) ctx.getIo()).allOutput()).contains("boo");
}
@Test
void startQuestStartsQuestInLog() {
GameContext ctx = ctx(Map.of());
Effects.apply(new Effect(Effect.Type.START_QUEST, "restore_power"), ctx);
assertThat(ctx.getQuestLog().isActive("restore_power")).isTrue();
}
}

View File

@@ -0,0 +1,30 @@
package thb.jeanluc.adventure.game;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class QuestLogTest {
@Test
void startAdvanceComplete() {
QuestLog log = new QuestLog();
assertThat(log.isActive("q")).isFalse();
log.start("q");
assertThat(log.isActive("q")).isTrue();
assertThat(log.stageIndex("q")).isEqualTo(0);
log.advance("q");
assertThat(log.stageIndex("q")).isEqualTo(1);
log.complete("q");
assertThat(log.isActive("q")).isFalse();
assertThat(log.isCompleted("q")).isTrue();
}
@Test
void startIgnoredOnceCompleted() {
QuestLog log = new QuestLog();
log.start("q");
log.complete("q");
log.start("q");
assertThat(log.isActive("q")).isFalse();
assertThat(log.isCompleted("q")).isTrue();
}
}