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:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user