feat: restore hooks for flags, quest progress, switch state
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package thb.jeanluc.adventure.game;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import thb.jeanluc.adventure.model.item.SwitchableItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class RestoreHooksTest {
|
||||
|
||||
@Test
|
||||
void gameStateRestoreReplacesFlags() {
|
||||
GameState s = new GameState();
|
||||
s.set("old");
|
||||
s.restore(List.of("a", "b"));
|
||||
assertThat(s.isSet("old")).isFalse();
|
||||
assertThat(s.all()).containsExactlyInAnyOrder("a", "b");
|
||||
}
|
||||
|
||||
@Test
|
||||
void questLogRestoreReplacesProgress() {
|
||||
QuestLog q = new QuestLog();
|
||||
q.start("stale");
|
||||
q.restore(Map.of("active", 2), Set.of("done"));
|
||||
assertThat(q.isActive("stale")).isFalse();
|
||||
assertThat(q.stageIndex("active")).isEqualTo(2);
|
||||
assertThat(q.isCompleted("done")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void switchableSetStateDoesNotRunEffects() {
|
||||
SwitchableItem lamp = SwitchableItem.builder()
|
||||
.id("lamp").name("Lamp").description("d").light(true)
|
||||
.onText("on").offText("off").state(false).effects(List.of())
|
||||
.build();
|
||||
lamp.setState(true);
|
||||
assertThat(lamp.isOn()).isTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user