package com.gh.gamecenter.entity

import android.os.Parcelable
import android.text.TextUtils
import com.gh.common.constant.Config
import com.gh.gamecenter.common.entity.LinkEntity
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

/**
 * Created by LGT on 2016/7/1.
 */
@Parcelize
data class SubjectEntity(
    @SerializedName("_id", alternate = ["link_id"])
    var id: String? = null,
    var name: String? = null,
    var more: Int? = null,
    @SerializedName("order")
    var isOrder: Boolean = false,
    var home: String? = null,
    var tag: String? = null,
    var sort: Int = 0,
    var data: MutableList<GameEntity>? = null,
    @SerializedName("type", alternate = ["link_type"])
    var type: String? = null,
    var des: String? = null,
    @SerializedName("relation_column_id")
    var relatedColumnId: String? = null,
    var style: String? = "", // 值为 "top" 时表示此专题(合集)为排行榜 https://gitlab.ghzs.com/pm/halo-app-issues/issues/699
    val list: Int = 0,
    @SerializedName("common_collection_content")
    var commonCollectionList: MutableList<CommonCollectionContentEntity>? = null,
    @SerializedName("home_page_style")
    var homePageStyle: String = "", //首页样式 （横排滑动：horizontal_sliding 竖排一行两个：1-2）
    @SerializedName("vertical_line")
    var verticalLine: String = "", // 竖排时才有数据，代表竖排行数控制

    @SerializedName("game_list_collection")
    var gameListCollection: List<GamesCollectionEntity>? = null,

    @SerializedName("show_name")
    var showName: Boolean = true, // 是否显示“专题名字”，true、false
    @SerializedName("show_suffix")
    var showSuffix: Boolean = true, // 是否显示”游戏后缀“，true、false
    @SerializedName("type_style")
    var typeStyle: String = "", // 横屏样式，不显示（default）、评分（star）、备注（remark）
    @SerializedName("brief_style")
    var briefStyle: String = "", // 简介样式，大小+简介（size&brief）、评分+简介（star&brief）、评分（star）、推荐优先（recommend）
    @SerializedName("more_link")
    var moreLink: LinkEntity? = null,

    // 开测表部分字段
    @SerializedName("index_right_top")
    var indexRightTop: String? = null,
    @SerializedName("index_right_top_link")
    var indexRightTopLink: LinkEntity? = null,
    var remark: String? = null, // 开测表备注

    var image: String = "",
    @SerializedName("first_line_recommend")
    var firstLineRecommend: String = "",
    @SerializedName("second_line_recommend")
    var secondLineRecommend: String = "",
    @SerializedName("recommend_tag")
    var recommendTag: String = "",
    @SerializedName("column_name")
    var columnName: String = "",

    // 专题合集，用于首页专题合集-排行榜样式
    var columns: MutableList<SubjectEntity> = mutableListOf(),
    // 专题背景，用于首页专题合集-排行榜样式
    var background: String = "",

    // 专题内游戏item是否显示下载按钮(目前只针对横向专题)
    @SerializedName("show_download")
    var showDownload: Boolean = false,
    @SerializedName("ad_icon_active")
    var adIconActive: Boolean = false,

    @SerializedName("link_text")
    var linkText: String = "",
    @SerializedName("display_content")
    var displayContent: String = "",
    @SerializedName("recommend_text")
    var recommendText: String = "",
    @SerializedName("link_game")
    var linkGame: GameEntity? = null,
    var position: Int = -1,

    // 本地字段，用来标记在外部页面中的序号，仅用于曝光记录，具体细节可见 https://git.ghzs.com/pm/halo-app-issues/-/issues/1087
    var outerSequence: Int = -1
) : Parcelable {

    fun getFilterName(): String {
        if (!TextUtils.isEmpty(name) && !Config.isShowPlugin()) {
            name = name?.replace("插件", "游戏")
        }
        return if (name == null) "" else name!!
    }
}