package com.gh.gamecenter.gamedetail.entity

import android.os.Parcelable
import androidx.annotation.Keep
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.entity.*
import com.gh.gamecenter.feature.entity.*
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize

@Keep
class DetailEntity(
    var type: String = "",
    @SerializedName("notice")
    var noticeList: ArrayList<NoticeEntity>? = null,
    var des: String? = null,// 介绍文案
    var gallery: ArrayList<String>? = null,
    @SerializedName("count")
    var videoCount: Int = 0,//视频数量
    var video: ArrayList<Video>? = null,
    var comment: ArrayList<RatingComment>? = null,
    var info: GameInfo? = null,
    var update: UpdateContent? = null,
    var libao: ArrayList<LibaoEntity>? = null,
    @SerializedName("related_version")
    var relatedVersion: ArrayList<RelatedVersion>? = null,
    var server: GameDetailServer? = null,
    @SerializedName("image_recommend")
    var imageRecommend: LinkEntity? = null,
    @SerializedName("custom_column")
    var customColumn: CustomColumn? = null,
    @SerializedName("related_game")
    var relatedGames: ArrayList<GameDetailRelatedGame>? = null,//原推荐游戏
    @SerializedName("download_game")
    var downloadGames: ArrayList<String>? = null,// 下载推荐
    @SerializedName("install_game")
    var installGames: ArrayList<String>? = null,// 安装推荐
    var recommendedGames: SubjectEntity? = null,
    var article: ArrayList<NewsEntity>? = null,
    @SerializedName("article_top")
    var articleTop: ArrayList<NewsEntity>? = null,
    @SerializedName("recommend_game_list")
    var recommendGameList: ArrayList<GameDetailRecommendGameEntity>? = null,
    //专题游戏单推荐
    @SerializedName("column_id")
    var columnId: String = "",
    @SerializedName("title")
    var columnTitle: String = "",
    @SerializedName("display.home")
    var displayHome: String = "",//右上角文案
    @SerializedName("size.index")
    var gameCount: Int = 0,//显示多少条数
    @SerializedName("display.more_link")
    var moreLink: LinkEntity? = null,
    @SerializedName("column_game")
    var columnGames: ArrayList<GameEntity>? = null,

    // 仅用于镜像
    @SerializedName(value = "new_tag_style")
    var tagStyle: ArrayList<TagStyleEntity> = ArrayList(),
    // 仅用于镜像
    var apk: ArrayList<ApkEntity>? = ArrayList(),
    // 仅用于镜像
    @SerializedName("custom_columns")
    var customColumnList: ArrayList<CustomColumn>? = null,
    // 仅用于镜像
    var manufacturer: String? = null,
    // 仅用于镜像
    @SerializedName("privacy_policy_url")
    var privacyPolicyUrl: String? = null,
    // 仅用于镜像
    @SerializedName("manufacturer_type")
    var manufacturerType: String = "",
    // 仅用于镜像
    var publisher: String = "",
    // 仅用于镜像
    var developer: String = "",
    // 仅用于镜像
    var supplier: String = "",
    // 仅用于镜像
    @SerializedName("credit_code")
    var creditCode: String = "",
    // 仅用于镜像
    @SerializedName("update_des")
    var updateDes: String = "",
    // 仅用于镜像
    @SerializedName("update_time")
    var updateTime: Long = 0,
    // 仅用于镜像
    @SerializedName("content_card_status")
    var contentCardStatus: String = "off", //on（生效）/off（不生效）

    @SerializedName("detail_dialogs")
    var detailDialogs: ArrayList<GameEntity.Dialog> = arrayListOf(),

    // 是否与前一个 item 连成整体，是否与后一个 item 连成整体
    var shouldBoundWithPreviousItem: Boolean = false,
    var shouldBoundWithNextItem: Boolean = false,
    // 上下 padding
    var paddingTop: Int = 0,
    var paddingBottom: Int = 0
) {

    enum class Type(val value: String) {
        IMAGE_GALLERY("gallery"),
        VIDEOS("video"),
        COMMENTS("comment"),
        GAME_INFO("info"),
        UPDATE_CONTENT("update"),
        LATEST_SERVER("server"),
        RELATED_VERSION("related_version"),
        IMAGE("image_recommend"),
        LIBAO("libao"),
        INFO_GUIDE("article"),
        RECOMMENDED_GAMES("related_game"),
        CUSTOM_COLUMN("custom_column"),
        DES("des"),
        NOTICE("notice"),
        RECOMMEND_GAME_LIST("recommend_game_list"),
        COLUMN_RECOMMEND("column_recommend"),
    }
}

//公告文章
@Keep
class NoticeEntity(
    @SerializedName("_id")
    var id: String = "",
    var title: String = "",
    var type: String = "",
    var time: String = "",
    var overtime: String = ""
)

@Keep
class CustomColumn(
    @SerializedName("_id")
    var id: String = "",
    var name: String = "",
    @SerializedName("show_name")
    var showName: Boolean? = true,
    @SerializedName("name_icon")
    var nameIcon: String? = "",
    @SerializedName("name_link")
    var nameLink: LinkEntity? = null,
    var link: LinkEntity? = null,
    var order: Long? = 0, // 权重
    var title: Title? = null,
    var des: String? = "",
    @SerializedName("tag_des")
    var desFull: String? = null,
    @SerializedName("tag_des_brief")
    var desBrief: String? = "",
    @SerializedName("show_des_type")
    var showDesType: String? = "",
    @SerializedName("show_des_row_num")
    var showDesRowNum: Int? = 3,
    @SerializedName("show_info_tag")
    var showInfoTag: Boolean? = false,
    @SerializedName("show_info_tag_des")
    var showInfoTagDes: Boolean? = false,
    @SerializedName("show_info_tag_des_type")
    var showInfoTagDesType: String? = "", // first_expand (用于默认展开), collapse, expand
    @SerializedName("info_tag")
    var infoTag: List<TagEntity>? = listOf(),
    var time: Long? = 0,

    var isHtmlDes: Boolean? = true,
    // 是否显示自定义栏目的提示浮窗 (本地字段)
    var showExpandTagsHint: Boolean? = false
)

@Keep
class Title(var icon: String, var value: String, var color: String)

@Keep
class UpdateContent(
    @SerializedName("history_apk_count")
    val historyApkCount: Int = 0,
    @SerializedName("history_apk_status")
    var historyApkStatus: String = "",
    @SerializedName("update_des")
    var updateDes: String = ""
)

@Keep
@Parcelize
class Video(
    @SerializedName("_id", alternate = ["video_id"])
    var videoId: String = "",
    @SerializedName(
        "new_video_count",
        alternate = ["video_count"]
    ) // 选用 JSON 最后一个值作为 videoCount 的值
    var videoCount: Int = 0,
    var poster: String = "",
    var title: String = "",
    var url: String = "",
    var user: User? = null,
    var vote: Int = 0
) : Parcelable

@Keep
@Parcelize
class RelatedVersion(
    var first: Boolean = false,
    var last: Boolean = false,
    var game: GameEntity? = null,
    @SerializedName("game_id")
    var gameId: String = "",
    @SerializedName("game_name")
    private var mGameName: String = "",
    @SerializedName("name_suffix")
    var nameSuffix: String? = "",
    @SerializedName("game_icon")
    var gameIcon: String = "",
    @SerializedName(value = "game_tag", alternate = arrayOf("new_game_tag"))
    var gameTags: ArrayList<TagStyleEntity> = ArrayList(),
    var index: Int
) : Parcelable {
    @IgnoredOnParcel
    val gameName: String
        get() = mGameName.removeSuffix(".") + (nameSuffix ?: "")
}