feat: switchable items apply effects when turned on

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 21:59:46 +02:00
parent 258ab4f63b
commit 00bad46661
4 changed files with 49 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
package thb.jeanluc.adventure.model.item;
import org.junit.jupiter.api.Test;
import thb.jeanluc.adventure.game.GameContext;
import thb.jeanluc.adventure.io.TestIO;
import thb.jeanluc.adventure.model.Effect;
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 SwitchEffectsTest {
@Test
void switchingOnAppliesEffects() {
SwitchableItem breaker = SwitchableItem.builder()
.id("breaker").name("Breaker").description("d")
.state(false).onText("hums to life").offText("off")
.effects(List.of(new Effect(Effect.Type.SET_FLAG, "power_on")))
.build();
Player player = new Player(new Room("k", "K", "d"), 0);
GameContext ctx = new GameContext(null, player, new TestIO());
breaker.use(ctx);
assertThat(ctx.getState().isSet("power_on")).isTrue();
}
}