package com.gh.gamecenter.pkg

import com.gh.gamecenter.BuildConfig
import com.gh.gamecenter.common.utils.toJsonIgnoredNull
import com.gh.gamecenter.core.provider.IPkgConfigProvider
import com.halo.assistant.HaloApp

@com.therouter.inject.ServiceProvider
class PkgConfigProviderImpl: IPkgConfigProvider {

    override fun getPkgConfig(): ArrayList<String> {
        val configList = arrayListOf<String>()

        val sdk = when  {
            BuildConfig.FLAVOR.contains("tea") -> "头条"
            BuildConfig.FLAVOR.contains("kuaishou") -> "快手"
            BuildConfig.FLAVOR.contains("gdt") -> "广点通"
            else -> "普通包"
        } + " " + BuildConfig.SDK_VERSION + " (仅头条有效)"

        val coreEvent = if (PkgHelper.getCoreEventGameCategory() == "online") {
            "网游"
        } else {
            "普通"
        }

        configList.add(sdk)
        if (BuildConfig.FLAVOR.contains("kuaishou")) {
            configList.add("appid: ${BuildConfig.SDK_APP_ID.ifEmpty { "81537" }}")
            configList.add("appname: ${BuildConfig.SDK_APP_NAME.ifEmpty { "guanghuanzhushou_1"}}")
        }

        configList.add(HaloApp.getInstance().channel)
        configList.add("${PkgHelper.getActivateRatio()}%")
        configList.add(coreEvent)
        configList.add(PkgHelper.getTempPkgConfigLink()?.toJsonIgnoredNull() ?: "")

        return configList
    }

}