Ejemplo n.º 1
0
        public static void ParseLine(string line)
        {
            var playerName = Parser.ParseName(line);

            if (playerName == "" || PlayerNames.Contains(playerName))
            {
                return;
            }

            var timeStamp = Parser.ParseDate(line);

            if (timeStamp < LastReadTime)
            {
                return;
            }
            LastReadTime = timeStamp;

            string mapName;
            string prefix;
            string suffix;

            Parser.ParseReport(line, out mapName, out prefix, out suffix);

            if (mapName == "")
            {
                return;
            }

            PlayerNames.Add(playerName);

            //Debug
            Console.WriteLine(string.Format("{0} {1} {2} by {3} at {4}", mapName, prefix, suffix, playerName, timeStamp));
            //Don't keep the main thread busy, communcation can hang and we don't want that if we can avoid it
            Task.Factory.StartNew(() => SendData(mapName, prefix, suffix));
        }
        /// <summary>
        /// Updates the UI when a player has joined.
        /// </summary>
        ///
        private void OnPlayerJoined(PlayerMessage message, Guid guid)
        {
            Guid duplicatePlayerID;

            if (!_playerToParticipantMap.TryGetValue(message.PlayerName, out duplicatePlayerID))
            {
                _playerToParticipantMap.Add(message.PlayerName, guid);

                if (PlayerNames.Contains(message.PlayerName))
                {
                    message.PlayerName += ".";
                }

                PlayerNames.Add(message.PlayerName);

                SubmittedAnswers.Add(message.PlayerName,
                                     new Dictionary <Question, int?>(Questions.Count));

                OnPropertyChanged(nameof(PlayerNames));
                OnPropertyChanged(nameof(SubmittedAnswers));
            }
        }
Ejemplo n.º 3
0
        public static string GetUuidByName(string playerName)
        {
            string result;

            if (Default.GUID.Count == PlayerNames.Count)
            {
                if (PlayerNames.Contains(playerName))
                {
                    int index = PlayerNames.IndexOf(playerName);
                    return(Default.GUID[index]);
                }
            }
            else
            {
                PlayerNames.Clear();
                Default.GUID.Clear();
            }
            result = Guid.NewGuid().ToString();
            PlayerNames.Add(playerName);
            Default.GUID.Add(result);
            Default.Save();
            return(result);
            //Console.WriteLine(result);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Checks if the specified player exists in the current room.
 /// </summary>
 /// <param name="name">The name of the player.</param>
 /// <returns>Whether the player with the specified name is in the current room.</returns>
 public bool PlayerExists(string name) => PlayerNames.Contains(x => x.ToLower() == name.ToLower());