package com.pixelized.shared.lwa

import com.pixelized.shared.lwa.model.AlteredCharacterSheetFactory
import com.pixelized.shared.lwa.model.alteration.AlterationJsonFactory
import com.pixelized.shared.lwa.model.campaign.factory.CampaignJsonFactory
import com.pixelized.shared.lwa.model.campaign.factory.CampaignJsonV1Factory
import com.pixelized.shared.lwa.model.campaign.factory.CampaignJsonV2Factory
import com.pixelized.shared.lwa.model.characterSheet.factory.CharacterSheetJsonFactory
import com.pixelized.shared.lwa.model.characterSheet.factory.CharacterSheetJsonV1Factory
import com.pixelized.shared.lwa.model.inventory.factory.InventoryJsonFactory
import com.pixelized.shared.lwa.model.inventory.factory.InventoryJsonFactoryV1
import com.pixelized.shared.lwa.model.item.factory.ItemJsonFactory
import com.pixelized.shared.lwa.model.item.factory.ItemJsonFactoryV1
import com.pixelized.shared.lwa.model.map.factory.MapJsonFactory
import com.pixelized.shared.lwa.model.map.factory.MapJsonFactoryV1
import com.pixelized.shared.lwa.model.tag.TagJsonFactory
import com.pixelized.shared.lwa.parser.dice.DiceParser
import com.pixelized.shared.lwa.parser.expression.ExpressionParser
import com.pixelized.shared.lwa.parser.word.WordParser
import com.pixelized.shared.lwa.usecase.CharacterSheetUseCase
import com.pixelized.shared.lwa.usecase.ExpressionUseCase
import com.pixelized.shared.lwa.usecase.RollUseCase
import com.pixelized.shared.lwa.usecase.SkillStepUseCase
import com.pixelized.shared.lwa.usecase.SkillUseCase
import kotlinx.serialization.json.Json
import org.koin.core.module.dsl.factoryOf
import org.koin.dsl.module

val sharedModuleDependencies
    get() = listOf(
        toolsDependencies,
        factoryDependencies,
        parserDependencies,
        useCaseDependencies,
    )

val toolsDependencies
    get() = module {
        factory {
            Json {
                ignoreUnknownKeys = true
                encodeDefaults = true
                explicitNulls = false
                prettyPrint = true
            }
        }
    }

val factoryDependencies
    get() = module {
        factoryOf(::CharacterSheetJsonFactory)
        factoryOf(::CharacterSheetJsonV1Factory)
        factoryOf(::CampaignJsonFactory)
        factoryOf(::CampaignJsonV1Factory)
        factoryOf(::CampaignJsonV2Factory)
        factoryOf(::AlteredCharacterSheetFactory)
        factoryOf(::AlterationJsonFactory)
        factoryOf(::TagJsonFactory)
        factoryOf(::ItemJsonFactory)
        factoryOf(::ItemJsonFactoryV1)
        factoryOf(::InventoryJsonFactory)
        factoryOf(::InventoryJsonFactoryV1)
        factoryOf(::MapJsonFactory)
        factoryOf(::MapJsonFactoryV1)
    }

val parserDependencies
    get() = module {
        factoryOf(::WordParser)
        factoryOf(::DiceParser)
        factoryOf(::ExpressionParser)
    }

val useCaseDependencies
    get() = module {
        factoryOf(::CharacterSheetUseCase)
        factoryOf(::SkillUseCase)
        factoryOf(::SkillStepUseCase)
        factoryOf(::RollUseCase)
        factoryOf(::ExpressionUseCase)
        factoryOf(::CharacterSheetUseCase)
    }