feat(loader): load combinations.yaml; demo matches+torch -> lit_torch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package thb.jeanluc.adventure.loader;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import thb.jeanluc.adventure.game.Combinations;
|
||||
import thb.jeanluc.adventure.game.GameContext;
|
||||
import thb.jeanluc.adventure.game.GameSession;
|
||||
import thb.jeanluc.adventure.io.TestIO;
|
||||
import thb.jeanluc.adventure.model.Combination;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CombinationLoadingTest {
|
||||
|
||||
@Test
|
||||
void realWorldLoadsTheTorchRecipe() {
|
||||
WorldLoader.LoadResult loaded = new WorldLoader().load();
|
||||
assertThat(loaded.world().getCombinations())
|
||||
.containsKey(Combination.key("matches", "torch"));
|
||||
assertThat(loaded.world().getItems()).containsKeys("matches", "torch", "lit_torch");
|
||||
}
|
||||
|
||||
@Test
|
||||
void torchRecipeWorksEndToEnd() {
|
||||
WorldLoader.LoadResult loaded = new WorldLoader().load();
|
||||
GameContext ctx = new GameContext(
|
||||
new GameSession(loaded.world(), loaded.player(), "test"), new TestIO());
|
||||
// grab the demo items straight from the registry, regardless of room
|
||||
ctx.getPlayer().addItem(ctx.getWorld().getItems().get("matches"));
|
||||
ctx.getPlayer().addItem(ctx.getWorld().getItems().get("torch"));
|
||||
Combinations.tryUse(ctx, "matches", "torch");
|
||||
assertThat(ctx.getPlayer().hasItem("lit_torch")).isTrue();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import org.junit.jupiter.api.Test;
|
||||
import thb.jeanluc.adventure.model.Direction;
|
||||
import thb.jeanluc.adventure.model.NpcReaction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class WorldLoaderTest {
|
||||
@@ -14,7 +16,7 @@ class WorldLoaderTest {
|
||||
|
||||
assertThat(result.world().getTitle()).isEqualTo("Test Manor");
|
||||
assertThat(result.world().getRooms().keySet()).containsExactlyInAnyOrder("kitchen", "hallway");
|
||||
assertThat(result.world().getItems().keySet()).containsExactlyInAnyOrder("letter", "lamp", "key");
|
||||
assertThat(result.world().getItems().keySet()).containsAll(List.of("letter", "lamp", "key"));
|
||||
assertThat(result.world().getNpcs().keySet()).containsExactly("old_man");
|
||||
|
||||
assertThat(result.player().getCurrentRoom().getId()).isEqualTo("kitchen");
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
- a: matches
|
||||
b: torch
|
||||
consume: [matches, torch]
|
||||
produce: lit_torch
|
||||
response: |
|
||||
You strike a match and touch it to the torch; it catches with a low hiss
|
||||
and burns steady. You now hold a lit torch.
|
||||
@@ -17,3 +17,19 @@
|
||||
id: key
|
||||
name: Key
|
||||
description: A key.
|
||||
|
||||
- type: plain
|
||||
id: matches
|
||||
name: Box of Matches
|
||||
description: A small box of dry matches.
|
||||
|
||||
- type: plain
|
||||
id: torch
|
||||
name: Unlit Torch
|
||||
description: A pitch-soaked torch.
|
||||
|
||||
- type: plain
|
||||
id: lit_torch
|
||||
name: Lit Torch
|
||||
description: A burning torch.
|
||||
light: true
|
||||
|
||||
Reference in New Issue
Block a user