示例#1
0
        /// <summary>
        /// Adds a game room the the list.
        /// </summary>
        /// <param name="username">The username of the room creator.</param>
        /// <param name="minutesPerPlayer">The time per player when the game starts.</param>
        /// <returns>The ID of the room created.</returns>
        public int AddGameRoom(string username, int minutesPerPlayer)
        {
            ChessGameRoom gameRoom;

            lock (this.GameRoomList)
            {
                gameRoom = new ChessGameRoom(GetNewID(), username, minutesPerPlayer);
                this.GameRoomList.Add(gameRoom);
            }

            return(gameRoom.ID);
        }
示例#2
0
        /// <summary>
        /// Gets a RoomInfo object reference containing room informations.
        /// </summary>
        /// <param name="roomID">The uniq ID of the room.</param>
        /// <returns>A RoomInfo object reference containing room informations.</returns>
        public RoomInfo GetRoomInfo(int roomID)
        {
            RoomInfo      roomInfo = new RoomInfo();
            ChessGameRoom gameRoom = this.GetRoomFromID(roomID);

            lock (this.GameRoomList)
            {
                roomInfo = gameRoom.GetRoomInfo();
            }

            return(roomInfo);
        }
示例#3
0
        /// <summary>
        /// Gets a ChessGameRoom object reference for a given ID.
        /// </summary>
        /// <param name="roomID">The room's ID.</param>
        /// <returns>A ChessGameRoom object.</returns>
        public ChessGameRoom GetRoomFromID(int roomID)
        {
            ChessGameRoom gameRoom = new ChessGameRoom();

            foreach (ChessGameRoom cgr in this.GameRoomList)
            {
                if (cgr.ID == roomID)
                {
                    gameRoom = cgr;
                }
            }

            return(gameRoom);
        }
示例#4
0
        /// <summary>
        /// Executes a command in the given room.
        /// </summary>
        /// <param name="roomID">The room's ID.</param>
        public void ExecuteCommandInRoom(AuthenticatedClient client, ChessCommand command)
        {
            ChessGameRoom gameRoom = this.GetRoomFromID(command.RoomID);

            gameRoom.ExecuteCommand(client, command);
        }