This class that handles the information about a match. Functionality: We can add a user or remove a user to the match.
Authors: Jeff, Rosanna, Jens (Server Team). Comments by Nadia and Rosanna. Updated by: NA
Ejemplo n.º 1
0
 /// <summary>
 /// Sends the current readylist to everyone in a match.
 /// </summary>
 /// <param name="match"></param>
 public void UpdateReadyCount(Match match)
 {
     int readyCount = 0;
     foreach (User user in match.Users)
         if (user.Ready)
             readyCount++;
     foreach (User user in match.Users)
         Clients.Client(user.ConnectionId).updateReadyCount(readyCount);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates an new empty match.
        /// </summary>
        /// <returns></returns>
        private Match CreateMatch()
        {
            // Create an empty match
            Match match = new Match();
            _matches.TryAdd(match.Id, match);

            return match;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sends the current userlist to everyone in a match.
        /// </summary>
        /// <param name="match"></param>
        public void UpdateMatchUserLists(Match match)
        {
            // Convert userlist to JSON
            string[] userlist = new string[match.Users.Count];
            for (int i = 0; i < match.Users.Count; i++)
                userlist[i] = ((User)match.Users[i]).Name;
            JavaScriptSerializer js = new JavaScriptSerializer();
            string json = js.Serialize(userlist);

            // Send JSON to each user in the match
            foreach (User user in match.Users)
                Clients.Client(user.ConnectionId).updateUserList(json);
        }