Esempio n. 1
0
    public async Task FromDdstatsUrl(string url, [Remainder] string?description = null)
    {
        if (await GetDdstatsResponse(url) is not {
        } ddStatsRun)
        {
            return;
        }

        if (await IsError(!ddStatsRun.GameInfo.Spawnset.Equals("v3", StringComparison.InvariantCultureIgnoreCase), "That's not a V3 run."))
        {
            return;
        }

        Split[] splits = RunAnalyzer.GetData(ddStatsRun);
        if (await IsError(splits.Any(s => s.Value > 1000), "Invalid run: too many homings gained on some splits."))
        {
            return;
        }

        string desc = description ?? $"{ddStatsRun.GameInfo.PlayerName} {ddStatsRun.GameInfo.GameTime:0.0000}";

        (BestSplit[] OldBestSplits, BestSplit[] UpdatedBestSplits)response = await _databaseHelper.UpdateBestSplitsIfNeeded(splits, ddStatsRun, desc);

        if (response.UpdatedBestSplits.Length == 0)
        {
            await InlineReplyAsync("No updates were needed.");

            return;
        }

        Embed updatedRolesEmbed = EmbedHelper.UpdatedSplits(response.OldBestSplits, response.UpdatedBestSplits);

        await ReplyAsync(embed : updatedRolesEmbed, allowedMentions : AllowedMentions.None, messageReference : Context.Message.Reference);
    }
Esempio n. 2
0
    public async Task FromDdstatsUrl(string url, uint splitName, [Remainder] string?description = null)
    {
        string[] v3SplitNames = Split.V3Splits.Select(s => s.Name).ToArray();
        if (await IsError(!v3SplitNames.Contains(splitName.ToString()), $"The split `{splitName}` doesn't exist."))
        {
            return;
        }

        if (await GetDdstatsResponse(url) is not {
        } ddStatsRun)
        {
            return;
        }

        if (await IsError(!ddStatsRun.GameInfo.Spawnset.Equals("v3", StringComparison.InvariantCultureIgnoreCase), "That's not a V3 run."))
        {
            return;
        }

        Split?split = RunAnalyzer.GetData(ddStatsRun).FirstOrDefault(s => s.Name == splitName.ToString());

        if (await IsError(split is null, $"The split `{splitName}` isn't in the run.") ||
            await IsError(split !.Value > 1000, "Invalid run: too many homings gained on that split."))
        {
            return;
        }

        string desc = description ?? $"{ddStatsRun.GameInfo.PlayerName} {ddStatsRun.GameInfo.GameTime:0.0000}";

        (BestSplit[] OldBestSplits, BestSplit[] UpdatedBestSplits)response = await _databaseHelper.UpdateBestSplitsIfNeeded(new[] { split }, ddStatsRun, desc);

        if (response.UpdatedBestSplits.Length == 0)
        {
            await InlineReplyAsync("No updates were needed.");

            return;
        }

        Embed updatedRolesEmbed = EmbedHelper.UpdatedSplits(response.OldBestSplits, response.UpdatedBestSplits);

        await ReplyAsync(embed : updatedRolesEmbed, allowedMentions : AllowedMentions.None, messageReference : Context.Message.Reference);
    }