package com.adealink.weparty.module.room.data

import android.os.Parcelable
import com.adealink.weparty.module.profile.data.UserInfo
import com.google.gson.annotations.GsonNullable
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

data class MyRoomInfo(
    @SerializedName("homeowner") val isOwner: Boolean,
    @SerializedName("roomTitle") var roomTitle: String,
    @SerializedName("roomCover") var roomCover: String,
    @SerializedName("forbidAudio") var forbidAudio: Boolean,
    @GsonNullable
    @SerializedName("roomTypes") val roomTypes: List<Int>?
) {
    fun canCreateRoom(): Boolean {
        return isOwner && !roomTypes.isNullOrEmpty()
    }
}


@Parcelize
data class RoomInfo(
    @SerializedName("roomId") val roomId: String,
    @SerializedName("roomTitle") val roomTitle: String,
    @SerializedName("roomCover") val roomCover: String,
    @SerializedName("roomType") val roomType: Int,
    @SerializedName("user") val owner: UserInfo,
) : Parcelable {

    fun isSupportedRoomType(): Boolean {
        return RoomType.isSupportRoomType(roomType)
    }

}

infix fun RoomInfo.contentsTheSame(other: RoomInfo): Boolean =
    roomId == other.roomId


fun RoomInfo.toEnterRoomInfo(password: String? = null): EnterRoomInfo {
    return EnterRoomInfo(roomId, this, password)
}

@Parcelize
data class EnterRoomInfo(
    val roomId: String,
    val roomInfo: RoomInfo? = null,
    var password: String? = null,
) : Parcelable
