package thb.jeanluc.adventure.loader;

import org.junit.jupiter.api.Test;
import thb.jeanluc.adventure.loader.dto.ConditionDto;
import thb.jeanluc.adventure.loader.dto.EffectDto;
import thb.jeanluc.adventure.loader.dto.QuestDto;
import thb.jeanluc.adventure.loader.dto.QuestStageDto;
import thb.jeanluc.adventure.model.Effect;
import thb.jeanluc.adventure.model.Quest;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

class QuestLoadingTest {
    @Test
    void factoryMapsStagesConditionsAndEffects() {
        QuestDto dto = new QuestDto("q", "Title", true,
                List.of(new QuestStageDto("obj",
                        List.of(new ConditionDto("power_on", null, null)),
                        List.of(new EffectDto("done", null, null, null, null)))),
                List.of());

        Quest q = QuestFactory.fromDto(dto);

        assertThat(q.autoStart()).isTrue();
        assertThat(q.stages()).hasSize(1);
        assertThat(q.stages().getFirst().objective()).isEqualTo("obj");
        assertThat(q.stages().getFirst().completion()).hasSize(1);
        assertThat(q.stages().getFirst().onComplete().getFirst().type()).isEqualTo(Effect.Type.SET_FLAG);
    }

    @Test
    void startQuestEffectMaps() {
        assertThat(new EffectDto(null, null, null, null, null, "q").toModel().type())
                .isEqualTo(Effect.Type.START_QUEST);
    }
}
