コード例 #1
0
        /// <summary>
        /// Add a user to the queue
        /// </summary>
        /// <param name="user"></param>
        public bool QueueUser(MRKToSUser user)
        {
            if (MatchState != State.Waiting)
            {
                MRKToSLogger.LogError($"Can not queue {user.Username} to the match, match has already started or is still idle");
                return(false);
            }

            if (FindQueuedUser(user.Username) != null)
            {
                MRKToSLogger.LogWarning($"User {user.Username} is already queued");
                return(false);
            }

            if (m_QueuedUsers.Count >= Settings.MaximumPlayerCount)
            {
                MRKToSLogger.LogWarning($"Can not que {user.Username} to the match, match has maximum player count");
                return(false);
            }

            m_QueuedUsers.Add(user);

            MRKToSLogger.LogInfo($"User {user.Username} has been added to the queue");
            LogQueueCount();

            MatchListener.OnQueueUserAdded(user);

            UpdatePregame();
            return(true);
        }
コード例 #2
0
 public MRKToSPlayer(MRKToSUser user, MRKToSMatch match, int id)
 {
     User      = user;
     Match     = match;
     ID        = id;
     m_Roles   = new List <MRKToSRole>();
     m_Scrolls = new Dictionary <MRKToSRoleID, MRKToSScroll>(); //TODO import from user
 }
コード例 #3
0
        static void Main(string[] args)
        {
            MRKToSLogger.RegisterLogger((t, m) => WriteLine($"[LOGGER] [{t}] {m}"));

            MRKToSGamemode      gamemodeCustom = new MRKToSGamemode("Custom", MRKToSRoleID.Bodyguard, MRKToSRoleID.Bodyguard);
            MRKToSMatchSettings settings       = new MRKToSMatchSettings(1, (uint)gamemodeCustom.RoleList.Count, 60, 10, gamemodeCustom);
            MRKToSMatch         match          = new MRKToSMatch(settings, new MatchListener(), null);

            ms_Match = match;

            match.Start();

            Dictionary <string, MRKToSUser> users = new Dictionary <string, MRKToSUser>();

            while (true)
            {
                if (match.MatchState == MRKToSMatch.State.Waiting)
                {
                    Write("Join: ");
                    string user  = ReadLine();
                    string _user = user.Replace("_", "");

                    if (!users.ContainsKey(_user))
                    {
                        users[_user] = new MRKToSUser(_user, 0);
                    }

                    if (user.Contains("_"))
                    {
                        match.DequeueUser(users[_user]);
                    }
                    else
                    {
                        match.QueueUser(users[_user]);
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Remove a user from the queue
        /// </summary>
        /// <param name="user"></param>
        public bool DequeueUser(MRKToSUser user)
        {
            if (MatchState != State.Waiting)
            {
                MRKToSLogger.LogError($"Can not dequeue {user.Username} to the match, match has already started or is still idle");
                return(false);
            }

            if (FindQueuedUser(user.Username) == null)
            {
                MRKToSLogger.LogWarning($"User {user.Username} is not queued");
                return(false);
            }

            m_QueuedUsers.Remove(user);

            MRKToSLogger.LogInfo($"User {user.Username} has been removed from the queue");
            LogQueueCount();

            MatchListener.OnQueueUserRemoved(user);

            UpdatePregame();
            return(true);
        }
コード例 #5
0
 public void OnQueueUserRemoved(MRKToSUser user)
 {
     WriteLine($"[MATCH] User {user.Username} has left.");
 }
コード例 #6
0
 public void OnQueueUserAdded(MRKToSUser user)
 {
     WriteLine($"[MATCH] User {user.Username} has joined.");
 }