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();
    }
}
