import com.pixelized.server.lwa.logics.ItemUsageLogic
import com.pixelized.server.lwa.services.alteration.AlterationService
import com.pixelized.server.lwa.services.alteration.AlterationStore
import com.pixelized.server.lwa.services.campaign.CampaignService
import com.pixelized.server.lwa.services.campaign.CampaignStore
import com.pixelized.server.lwa.services.character.CharacterSheetService
import com.pixelized.server.lwa.services.character.CharacterSheetStore
import com.pixelized.server.lwa.services.inventory.InventoryService
import com.pixelized.server.lwa.services.inventory.InventoryStore
import com.pixelized.server.lwa.services.item.ItemService
import com.pixelized.server.lwa.services.item.ItemStore
import com.pixelized.server.lwa.services.tag.TagService
import com.pixelized.server.lwa.services.tag.TagStore
import com.pixelized.server.lwa.server.Engine
import com.pixelized.server.lwa.services.map.MapService
import com.pixelized.server.lwa.services.map.MapStore
import com.pixelized.shared.lwa.utils.PathProvider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import org.koin.core.module.dsl.createdAtStart
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module

val serverModuleDependencies
    get() = listOf(
        toolsDependencies,
        engineDependencies,
        storeDependencies,
        serviceDependencies,
        logicsDependencies,
    )

val toolsDependencies
    get() = module {
        single {
            PathProvider(appName = "LwaServer")
        }
        factory<CoroutineScope> {
            CoroutineScope(Job())
        }
    }

val engineDependencies
    get() = module {
        singleOf(constructor = ::Engine, options = { createdAtStart() })
    }

val storeDependencies
    get() = module {
        singleOf(::AlterationStore)
        singleOf(::CampaignStore)
        singleOf(::CharacterSheetStore)
        singleOf(::InventoryStore)
        singleOf(::ItemStore)
        singleOf(::TagStore)
        singleOf(::MapStore)
    }

val serviceDependencies
    get() = module {
        singleOf(::AlterationService)
        singleOf(::CampaignService)
        singleOf(::CharacterSheetService)
        singleOf(::InventoryService)
        singleOf(::ItemService)
        singleOf(::TagService)
        singleOf(::MapService)
    }

val logicsDependencies
    get() = module {
        singleOf(::ItemUsageLogic)
    }
