Esempio n. 1
0
        public ParticipantInfo GetParticipantInfo(string username)
        {
            ParticipantInfo participantInfo = new ParticipantInfo();
            var             rawRows         = ReadEntries($"{username}!D13:J");

            for (int i = rawRows.Count - 1; i > 0; i--)
            {
                if (rawRows[i].Count == 7 && rawRows[i][1].ToString() != "" && rawRows[i][2].ToString() != "")
                {
                    participantInfo.Name       = username;
                    participantInfo.Game       = (string)rawRows[i][1];
                    participantInfo.NominalGgp = (string)rawRows[i][3];
                    participantInfo.Events     = (string)rawRows[i][6];
                    participantInfo.Events     = participantInfo.Events.Replace("\n", ", ");
                    break;
                }
            }

            for (int i = rawRows.Count - 1; i > 0; i--)
            {
                if (rawRows[i].Count != 0 && rawRows[i][0].ToString() != "")
                {
                    participantInfo.Section = rawRows[i][0].ToString();
                    break;
                }
            }

            return(participantInfo);
        }
Esempio n. 2
0
        private async void SendGamefaqMessage(string username, string message, string channel)
        {
            username = SendAMessageTo(username, ref message);
            string          result;
            GamefaqStats    stats;
            ParticipantInfo participantInfo = HasAParicipantAlias(message);

            if (participantInfo != null)
            {
                stats = await gamefaqParser.ParseGame(participantInfo.Game);
            }
            else
            {
                stats = await gamefaqParser.ParseGame(message);
            }

            if (stats != null)
            {
                result = $"Length: {stats.Time}. Completed: {stats.Completed}. Rating: {stats.Rating}";
            }
            else
            {
                result = "не удалось найти информацию об этой игре";
            }

            client.SendMessage(channel, $"@{username} {result}");
        }
Esempio n. 3
0
        private async void SendHltbMessage(string username, string message, string channel)
        {
            username = SendAMessageTo(username, ref message);
            string          result;
            ParticipantInfo participantInfo = HasAParicipantAlias(message);

            string[] times;
            if (participantInfo != null)
            {
                times = await hltbParser.ParseGame(participantInfo.Game);
            }
            else
            {
                times = await hltbParser.ParseGame(message);
            }

            if (times != null)
            {
                result = $"Main story: {times[0].Replace("½", ".5")}. Main+Extra: {times[1].Replace("½", ".5")}";
            }
            else
            {
                result = "не удалось найти информацию об этой игре";
            }

            client.SendMessage(channel, $"@{username} {result}");
        }
Esempio n. 4
0
        private static async void UpdateParticipantInfo(string name)
        {
            while (true)
            {
                ParticipantInfo newParticipantInfo = hpgDocParser.GetParticipantInfo(ParticipantDictionary[name].Name);
                if (newParticipantInfo.Game == ParticipantDictionary[name].Game)
                {
                    newParticipantInfo.HoursToComplete = ParticipantDictionary[name].HoursToComplete;
                    newParticipantInfo.FinalGgp        = ParticipantDictionary[name].FinalGgp;
                }
                else
                {
                    string[] hltbTimes = await hltbParser.ParseGame(newParticipantInfo.Game);

                    if (hltbTimes != null)
                    {
                        newParticipantInfo.HoursToComplete = hltbTimes[0];
                    }
                    else
                    {
                        newParticipantInfo.HoursToComplete = "---";
                    }
                    newParticipantInfo.FinalGgp = hpgDocParser.GetLastGameGgp(newParticipantInfo);
                }
                ParticipantDictionary[name] = newParticipantInfo;
                Thread.Sleep(Delay * 1000);
            }
        }
Esempio n. 5
0
        private void SendEventMessage(string username, string message, string channel)
        {
            username = SendAMessageTo(username, ref message);
            string          result;
            ParticipantInfo participantInfo = HasAParicipantAlias(message);

            if (participantInfo != null)
            {
                result = participantInfo.Events;
            }
            else
            {
                result = "участник не найден.";
            }
            client.SendMessage(channel, $"@{username} {result}");
        }
Esempio n. 6
0
        private void SendGameMessage(string username, string message, string channel)
        {
            username = SendAMessageTo(username, ref message);
            string          result;
            ParticipantInfo participantInfo = HasAParicipantAlias(message);

            if (participantInfo != null)
            {
                result = $"[{participantInfo.Section}] {participantInfo.Game}. Время прохождения: {participantInfo.HoursToComplete.Trim()}. Номинальное GGP: {participantInfo.NominalGgp} [{participantInfo.FinalGgp}]";
            }
            else
            {
                result = "участник не найден.";
            }
            client.SendMessage(channel, $"@{username} {result}");
        }
Esempio n. 7
0
        public string GetLastGameGgp(ParticipantInfo participantInfo)
        {
            try
            {
                int    ggp                = Convert.ToInt32(participantInfo.NominalGgp);
                string events             = participantInfo.Events;
                string procentsPattern    = @"((?:\-|\+|\−)\d+)%+";
                string streakPattern      = @"(?:Стрик|стрик|Стрик|Cтрик)[\s\S]+\+(\d+)"; // @"Стрик[\s\S]+(\+\d+)[\s\S]+
                string buhgalteryPattern  = @"(?:Бухгалтерия|бухгалтерия)[\s\S]*\(+(\d+)\)+";
                string buhgalteryPattern2 = @"(?:Бухгалтерия|бухгалтерия)[\s\S]+=(\d+)";

                Regex r             = new Regex(buhgalteryPattern);
                Match buhgalteryGgp = r.Match(events);
                if (buhgalteryGgp.Length != 0)
                {
                    ggp = Convert.ToInt32(string.Join("", buhgalteryGgp.Groups[1].Value.Where(char.IsDigit)));
                }

                r             = new Regex(buhgalteryPattern2);
                buhgalteryGgp = r.Match(events);
                if (buhgalteryGgp.Length != 0)
                {
                    ggp = Convert.ToInt32(buhgalteryGgp.Groups[1].ToString());
                }

                r = new Regex(procentsPattern);
                MatchCollection matches = r.Matches(events);
                if (matches.Count != 0)
                {
                    int procents = 100;
                    foreach (Match match in matches)
                    {
                        char operand = match.Value[0];
                        int.TryParse(string.Join("", match.Value.Where(char.IsDigit)), out var number);
                        if (operand == '+')
                        {
                            procents += number;
                        }
                        else
                        {
                            procents -= number;
                        }
                    }

                    if (procents < 40)
                    {
                        procents = 40;
                    }

                    double multiplier = (procents / 100.0);
                    ggp = Convert.ToInt32(Math.Floor(ggp * multiplier));
                }

                r = new Regex(streakPattern);
                Match streak = r.Match(events);
                if (streak.Length != 0)
                {
                    ggp += Convert.ToInt32(streak.Groups[1].ToString());
                }

                return("Итоговое GGP: " + ggp);
            }
            catch
            {
                return("---");
            }
        }