Beispiel #1
0
        async Task ICeaSubCommand.Run(SocketSlashCommand command, DiscordSocketClient client, IReadOnlyDictionary<SlashCommandOptions, string> options, Lazy<List<Team>> lazyTeams)
        {
            Bracket bracket = LeagueManager.League.Bracket.Brackets.First();
            string stage = StageMatcher.Lookup(bracket.Rounds.Last().RoundName);
            string rematches = StageRematchFinder.FindRematches(bracket, stage);

            await command.RespondAsync(rematches, ephemeral: true);
        }
Beispiel #2
0
        internal static void AddHistoryToEmbed(EmbedBuilder builder, Team team, BracketSet bracket)
        {
            StringBuilder sb = new();

            foreach (BracketRound round in bracket.Rounds.SelectMany(r => r))
            {
                foreach (MatchResult result in round.Matches)
                {
                    if (result.HomeTeam == team || result.AwayTeam == team)
                    {
                        string awayString = result.Bye ? "BYE" : $"{result.AwayTeam}[{ result.AwayTeam.RoundRanking[round]}]";
                        sb.AppendLine($"[{result.HomeGamesWon}-{result.AwayGamesWon}] {result.HomeTeam} [{result.HomeTeam.RoundRanking[round]}] vs {awayString}");
                    }
                }
            }

            builder.AddField($"{team.Name}'s {StageMatcher.Lookup(bracket.Rounds.First().First().RoundName)} Match History", sb.ToString());
        }
Beispiel #3
0
        async Task ICeaSubCommand.Run(SocketSlashCommand command, DiscordSocketClient client, IReadOnlyDictionary <SlashCommandOptions, string> options, Lazy <List <Team> > lazyTeams)
        {
            BracketSet        currentBrackets    = LeagueManager.League.Bracket;
            BracketRound      currentRound       = currentBrackets.Rounds.Last().First();
            string            currentStage       = StageMatcher.Lookup(currentRound.RoundName);
            List <StageGroup> stageGroups        = ConfigurationManager.Configuration.stageGroups.ToList();
            List <StageGroup> currentStageGroups = stageGroups.Where(g => g.Stage.Equals(currentStage)).ToList();

            List <Embed> embeds = new();

            foreach (StageGroup group in currentStageGroups)
            {
                EmbedBuilder  builder = new();
                StringBuilder result  = new StringBuilder();
                int           page    = 0;
                List <Team>   teams   = group.Teams.OrderBy(t => t.RoundRanking[currentRound]).ToList();
                foreach (Team team in teams)
                {
                    TeamStatistics stats = team.StageStats[currentStage];
                    result.AppendLine($"{team.RoundRanking[currentRound]} {team} [**{stats.MatchWins}**-{stats.MatchLosses}] GoalDiff: {stats.TotalGoalDifferential}");
                    if (result.Length > 800)
                    {
                        builder.AddField(page == 0 ? $"{group.Name} Standings" : $"{group.Name} Continued", result.ToString());
                        result = new StringBuilder();
                        page++;
                    }
                }

                if (result.Length > 0)
                {
                    builder.AddField(page == 0 ? $"{group.Name} Standings" : $"{group.Name} Continued", result.ToString());
                }
                embeds.Add(builder.Build());
            }

            bool ephemeral = !options.ContainsKey(SlashCommandOptions.post) || !options[SlashCommandOptions.post].Equals("True");
            await command.RespondAsync(embeds : embeds.ToArray(), ephemeral : ephemeral);
        }