package com.gh.gamecenter.entity

import android.os.Parcelable
import com.gh.gamecenter.common.entity.IconFloat
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.feature.entity.TagStyleEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize

@Parcelize
data class AmwayCommentEntity(
    @SerializedName("_id")
    var id: String,
    var game: Game,
    var comment: RatingComment,
    var time: Long
) : Parcelable {

    @Parcelize
    data class Game(
        @SerializedName("_id")
        var id: String,
        var icon: String,
        @SerializedName("ori_icon")
        var rawIcon: String? = null,
        @SerializedName("icon_subscript")
        var iconSubscript: String? = "",
        @SerializedName("name")
        private var mName: String,
        @SerializedName(value = "new_tag_style")
        var tag: List<TagStyleEntity>? = arrayListOf(),
        @SerializedName("new_star")
        var star: Float,

        var subtitle: String? = "",
        @SerializedName("subtitle_style")
        var subtitleStyle: TagStyleEntity? = null,
        @SerializedName("icon_float")
        var iconFloat: IconFloat? = null,

        // 曝光用的位置
        var sequence: Int = 0,
        var outerSequence: Int = 0

    ) : Parcelable {

        @IgnoredOnParcel
        val name: String?
            get() = mName.removeSuffix(".")

        @IgnoredOnParcel
        var exposureEvent: ExposureEvent? = null

        fun toGameEntity(): GameEntity {
            val gameEntity = GameEntity()
            gameEntity.id = id
            gameEntity.name = name
            gameEntity.icon = icon
            gameEntity.rawIcon = rawIcon
            gameEntity.iconSubscript = iconSubscript
            gameEntity.iconFloat = iconFloat
            gameEntity.platform = ""

            gameEntity.subtitle = subtitle ?: ""
            gameEntity.subtitleStyle = subtitleStyle

            gameEntity.sequence = sequence
            gameEntity.outerSequence = outerSequence
            return gameEntity
        }
    }
}