import Foundation
import WebSocketKit

protocol ManageableTable {

    /// The unique id of the table
    var id: TableId { get }

    /// The name of the table
    var name: TableName { get }

    /// The table is visible in the list of tables and can be joined by anyone
    var isPublic: Bool { get }

    var playerNames: [PlayerName] { get }

    var allPlayers: [Player] { get }

    var publicInfo: PublicTableInfo { get }

    func tableInfo(forPlayer player: PlayerName) -> TableInfo

    func perform(action: PlayerAction, forPlayer: PlayerName) -> (result: PlayerActionResult, table: ManageableTable?)

    func play(card: Card, player name: PlayerName) -> (result: PlayerActionResult, table: ManageableTable?)

    func connect(player name: PlayerName, using socket: WebSocket) -> Bool

    func disconnect(player name: PlayerName)

    func sendUpdateToAllPlayers()
}
