feat: state-dependent room descriptions (LookCommand resolution)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package thb.jeanluc.adventure.command.impl;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import thb.jeanluc.adventure.game.GameContext;
|
||||
import thb.jeanluc.adventure.io.TestIO;
|
||||
import thb.jeanluc.adventure.model.Condition;
|
||||
import thb.jeanluc.adventure.model.DescriptionState;
|
||||
import thb.jeanluc.adventure.model.Player;
|
||||
import thb.jeanluc.adventure.model.Room;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class DescriptionStateTest {
|
||||
@Test
|
||||
void descriptionSwitchesWithFlag() {
|
||||
Room cellar = new Room("cellar", "Cellar", "Pitch black down here.");
|
||||
cellar.addDescriptionState(new DescriptionState(
|
||||
List.of(new Condition(Condition.Type.FLAG, "power_on")),
|
||||
"Lit now, a workbench stands against the wall."));
|
||||
Player player = new Player(cellar, 0);
|
||||
TestIO io = new TestIO();
|
||||
GameContext ctx = new GameContext(null, player, io);
|
||||
|
||||
new LookCommand().execute(ctx, List.of());
|
||||
assertThat(io.allOutput()).contains("Pitch black");
|
||||
|
||||
io.outputs().clear();
|
||||
ctx.getState().set("power_on");
|
||||
new LookCommand().execute(ctx, List.of());
|
||||
assertThat(io.allOutput()).contains("workbench").doesNotContain("Pitch black");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user