package com.gh.gamecenter.gamedetail.entity

import androidx.annotation.Keep
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.common.entity.ToolBoxEntity
import com.gh.gamecenter.feature.entity.GameDetailServer
import com.gh.gamecenter.feature.entity.LibaoEntity
import com.google.gson.annotations.SerializedName

@Keep
class ContentCardEntity(
    @SerializedName("_id")
    var id: String = "",
    var title: String? = "",
    var icon: String = "",
    var des: String = "",
    var link: LinkEntity = LinkEntity(), // 其中功能类，func_server：游戏开服、func_libao：游戏礼包、func_related_version：相关版本、func_zone：专区、func_tool_kit：工具、func_bbs：论坛、func_archive：云存档
    var server: GameDetailServer? = null,
    var libao: LibaoEntity? = null,
    @SerializedName("zone_tab")
    var zoneTab: Boolean = false,
    @SerializedName("related_version")
    var relatedVersion: Boolean = false,
    var toolkit: ArrayList<ToolBoxEntity> = ArrayList(),
    @SerializedName("func_bbs")
    val funcBbs: LinkEntity? = null,
    val archive: Archive? = null,
    val dialog: Dialog? = null,
    // 本地字段
    var showDes: Boolean = true,
    var showNewTag: Boolean = false,
) {

    val redDot
        get() = when (link.type) {
            TYPE_SERVER -> server?.total ?: 0
            TYPE_GIFT -> libao?.total ?: 0
            else -> 0
        }

    @Keep
    class Dialog(
        @SerializedName("_id")
        val id: String? = "",
        val title: String? = "",
        val body: String? = ""
    )

    @Keep
    class Archive(
        @SerializedName("_id")
        val id: String = "",
        val name: String = "",
        val time: Long = 0L
    )

    companion object {
        const val TYPE_GIFT = "func_libao"
        const val TYPE_SERVER = "func_server"
        const val TYPE_RELATED_VERSION = "func_related_version"
        const val TYPE_ZONE = "func_zone"
        const val TYPE_BBS = "func_bbs"
        const val TYPE_TOOLKIT = "func_tool_kit"
        const val TYPE_ARCHIVE = "func_archive"
    }
}
