import com.pixelized.server.lwa.logics.ItemUsageLogic
import com.pixelized.server.lwa.model.alteration.AlterationService
import com.pixelized.server.lwa.model.alteration.AlterationStore
import com.pixelized.server.lwa.model.campaign.CampaignService
import com.pixelized.server.lwa.model.campaign.CampaignStore
import com.pixelized.server.lwa.model.character.CharacterSheetService
import com.pixelized.server.lwa.model.character.CharacterSheetStore
import com.pixelized.server.lwa.model.inventory.InventoryService
import com.pixelized.server.lwa.model.inventory.InventoryStore
import com.pixelized.server.lwa.model.item.ItemService
import com.pixelized.server.lwa.model.item.ItemStore
import com.pixelized.server.lwa.model.tag.TagService
import com.pixelized.server.lwa.model.tag.TagStore
import com.pixelized.server.lwa.server.Engine
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)
    }

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

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