package com.gh.gamecenter.entity

import android.os.Parcelable
import com.gh.gamecenter.feature.entity.*
import com.gh.gamecenter.feature.entity.TimeEntity
import com.gh.gamecenter.room.converter.*
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

@Parcelize
data class HomeGameCollectionEntity(
    @SerializedName("_id")
    var id: String = "",
    var games: ArrayList<GameEntity>? = null,
    var title: String = "",
    var intro: String = "",
    var cover: String = "",
    var display: String = "",//self_only: 仅自己可见
    var stamp: String = "",//special_choice: 精选 offical: 官方
    var count: Count? = null,
    var user: User? = null,
    var time: TimeEntity? = null,
    @SerializedName("ad_icon_active")
    var adIconActive: Boolean = false,
) : Parcelable {

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as HomeGameCollectionEntity
        // 这里只对比游戏单id判断是否相同
        if (id != other.id) return false

        return true
    }

    override fun hashCode(): Int {
        var result = id.hashCode()
        result = 31 * result + (games?.hashCode() ?: 0)
        result = 31 * result + title.hashCode()
        result = 31 * result + intro.hashCode()
        result = 31 * result + cover.hashCode()
        result = 31 * result + display.hashCode()
        result = 31 * result + stamp.hashCode()
        result = 31 * result + (count?.hashCode() ?: 0)
        result = 31 * result + (user?.hashCode() ?: 0)
        result = 31 * result + (time?.hashCode() ?: 0)
        result = 31 * result + adIconActive.hashCode()
        return result
    }

}
