Exemple #1
0
        private void CalculatePPAndDifficulty(string beatmap)
        {
            EZPPResult ezpp = EZPP.Calculate(beatmap, MaxCombo, Count100, Count50, CountMiss, EnabledMods);

            MapMaxCombo        = ezpp.MaxCombo;
            MapTotalHitObjects = ezpp.TotalHitObjects;

            PP = ezpp.PP;

            double objectsEncountered = Count300 + Count100 + Count50 + CountMiss;

            Accuracy  = (double)((Count300 * 300.0) + (Count100 * 100.0) + (Count50 * 50.0)) / (double)(objectsEncountered * 300.0);
            Accuracy *= 100.0;

            //100 to 300 ratio
            double expectedCount100 = ((double)Count100 * MapTotalHitObjects) / objectsEncountered;

            //50 to 300 ratio
            double expectedCount50 = ((double)Count50 * MapTotalHitObjects) / objectsEncountered;

            ezpp = EZPP.Calculate(beatmap, ezpp.MaxCombo, (int)Math.Floor(expectedCount100), (int)Math.Floor(expectedCount50), 0, EnabledMods);

            PP_IF_FC       = ezpp.PP;
            IF_FC_Accuracy = ezpp.Accuracy;

            CompletionPercentage = (objectsEncountered / ezpp.TotalHitObjects) * 100;

            StarRating = ezpp.StarRating;
            CS         = ezpp.CS;
            AR         = ezpp.AR;
            OD         = ezpp.OD;
            HP         = ezpp.HP;
            BPM        = ezpp.BPM;

            SongName       = ezpp.SongName;
            DifficultyName = ezpp.DifficultyName;
            ArtistName     = ezpp.ArtistName;
        }
Exemple #2
0
        public CoreModule()
        {
            AddCMD("Enable a command", (sMsg, buffer) =>
            {
                string commandToEnable = buffer.GetRemaining();

                if (sMsg.Author.Id == Config.BotOwnerID)
                {
                    foreach (var module in LoadedModules)
                    {
                        foreach (var command in module.Commands)
                        {
                            if (command.Triggers.Contains(commandToEnable))
                            {
                                command.IsEnabled = true;
                                sMsg.Channel.SendMessageAsync($"Enabled **{commandToEnable}** in `{module.Name}`");
                                return;
                            }
                        }
                    }
                    sMsg.Channel.SendMessageAsync($"{commandToEnable} no such command found");
                }
            }, ".enable");

            AddCMD("Enable a command", (sMsg, buffer) =>
            {
                EmbedBuilder embedBuilder = new EmbedBuilder();
                embedBuilder.Title        = "Spider";
                string description        = "";

                description += "Claims #1\n";
                description += "Likes #1\n";
                description += "**9000** <:kakera:888490123388403762>";

                embedBuilder.Description = description;

                embedBuilder.Color = new Color(0, 0, 255);

                embedBuilder.ImageUrl = "https://cdn.discordapp.com/attachments/846519580126216233/888489091421831188/IMG_20210831_003940.jpg";

                sMsg.Channel.SendMessageAsync(embed: embedBuilder.Build());
            }, ".waifu");

            AddCMD("Disable a command", (sMsg, buffer) =>
            {
                string commandToDisable = buffer.GetRemaining();

                if (commandToDisable == ".disable" || commandToDisable == ".enable")
                {
                    return;
                }

                if (sMsg.Author.Id == Config.BotOwnerID)
                {
                    foreach (var module in LoadedModules)
                    {
                        foreach (var command in module.Commands)
                        {
                            if (command.Triggers.Contains(commandToDisable))
                            {
                                command.IsEnabled = false;
                                sMsg.Channel.SendMessageAsync($"Disabled **{commandToDisable}** in `{module.Name}`");
                                return;
                            }
                        }
                    }
                    sMsg.Channel.SendMessageAsync($"`{commandToDisable}` no such command found");
                }
            }, ".disable");

            AddCMD("Sends the url for the source code hosted on github", (sMsg, buffer) =>
            {
                sMsg.Channel.SendMessageAsync($"**Here is the source code for the bot:** {Config.GithubURL}");
            }, ".github", ".source", ".code");

            AddCMD("Shows bot info", (sMsg, buffer) =>
            {
                var runtimeVer = RuntimeInformation.FrameworkDescription;

                EmbedBuilder embed = new EmbedBuilder();

                embed.WithTitle("Bot Info");
                string desc = "";

                desc += $"[Github Link]({Config.GithubURL})\n";

                desc += $"Runtime: **{runtimeVer}**\n";
                desc += $"OS: **{RuntimeInformation.OSDescription} {RuntimeInformation.ProcessArchitecture}**\n";

                desc += Utils.GetCPUInfo();

                desc += $"Ram Usage: **{(Process.GetCurrentProcess().PrivateMemorySize64 / 1048576.0).ToString("F")} MB**\n";
                desc += $"CPU Time: **{Utils.FormatTime(Process.GetCurrentProcess().TotalProcessorTime, ago: false)}**\n";
                desc += $"GC: **0:** `{GC.CollectionCount(0)}` **1:** `{GC.CollectionCount(1)}` **2:** `{GC.CollectionCount(2)}`\n";
                desc += $"Oppai Version: **{EZPP.GetVersion()}**\n";
                desc += $"Ping: **{Client.Latency} MS**\n";
                desc += $"Run-Time: **{Utils.FormatTime(runTimeWatch.Elapsed, ago: false)}**\n";
                desc += $"Serving: **{Client.Guilds.Count} Guilds And {GetMemberCount()} Members**\n";
                desc += $"Commands Handled: **{TotalCommandsHandled}**\n";
                desc += $"Bancho API Calls: **{BanchoAPI.TotalAPICalls}**\n";
                desc += $"Loaded Modules: **{LoadedModules.Count}**\n";

                embed.WithDescription(desc);
                embed.WithColor(Color.Blue);
                sMsg.Channel.SendMessageAsync("", false, embed.Build());
            }, ".info");

            AddCMD("Shows this embed", (sMsg, buffer) =>
            {
                Pages commandPages = new Pages();

                EmbedBuilder builder = new EmbedBuilder();
                int commandCounter   = 1;
                string description   = "";

                void CompileEmbed()
                {
                    builder.WithAuthor("Available Commands", Client.CurrentUser.GetAvatarUrl());
                    builder.WithFooter($"{description.Length} chars");
                    builder.WithDescription(description);
                    commandPages.AddEmbed(builder.Build());
                    builder     = new EmbedBuilder();
                    description = "";
                }

                foreach (Module module in LoadedModules)
                {
                    string tempDesc = "";
                    tempDesc       += $"```fix\n{module.Name}```";
                    foreach (Command command in module.Commands)
                    {
                        tempDesc += $"`{commandCounter++}.` **{new CommandBuffer(command.Triggers, "").GetRemaining(", ")}** (*{command.Description}*)";
                        if (command.IsEnabled == false)
                        {
                            tempDesc += " -> `Has been disabled!`";
                        }
                        if (command.Cooldown > 0)
                        {
                            tempDesc += $" -> `Cooldown: {command.Cooldown}`";
                        }

                        tempDesc += "\n";

                        if (description.Length + tempDesc.Length < 2048)
                        {
                            description += tempDesc;
                            tempDesc     = "";
                        }
                        else
                        {
                            CompileEmbed();
                            description += tempDesc;
                        }
                    }
                }

                if (description.Length > 0)
                {
                    CompileEmbed();
                }

                sMsg.Channel.SendPages(commandPages);
            }, ".help");
        }