public static async Task <DsReplayDto?> ParseReplayAsync(string replayPath, string?assemblyPath = null) { if (!File.Exists(replayPath)) { return(null); } if (assemblyPath == null) { assemblyPath = _assemblyPath; } if (!Directory.Exists(assemblyPath)) { return(null); } ReplayDecoderOptions options = new ReplayDecoderOptions() { Details = true, Metadata = false, MessageEvents = false, TrackerEvents = true }; ReplayDecoder decoder = new ReplayDecoder(assemblyPath); Sc2Replay? replay = await decoder.DecodeAsync(replayPath); if (replay == null) { return(null); } return(GetReplayDto(replay)); }
private void loadFiles() { var bmPath = Path.Combine(osuRoot, "Songs", dmp.FolderName, dmp.FileName); var rpPath = Path.Combine(osuRoot, @"Data\r", $"{dmp.MD5Hash}-{sc.ScoreTimestamp.ToFileTimeUtc()}.osr"); bm = BeatmapDecoder.Decode(bmPath); rp = ReplayDecoder.Decode(rpPath); }
public void selectReplay(string replayPath) { if (!string.IsNullOrEmpty(replayPath)) { this.replayPath = replayPath; Console.WriteLine("Decoding replay, please wait..."); replay = ReplayDecoder.Decode(this.replayPath); replayFrames = replay.ReplayFrames; Console.WriteLine("Replay Loaded."); Console.WriteLine("Played by: " + replay.PlayerName); Console.WriteLine("Ruleset: " + replay.Ruleset); Console.WriteLine("Using mods: " + replay.Mods); if (shouldInterpolateReplay) { replayFrames = interpolateReplay(); } } }
static void RunOptions(Options opts) { // Parse Beatmap and replay var beatmap = new Beatmap(); var replay = new Replay(); try { beatmap = BeatmapDecoder.Decode(opts.BeatmapPath); } catch (Exception) { Console.WriteLine("Can not parse Beatmap " + opts.BeatmapPath); return; } if (opts.ReplayPath != null) { try { replay = ReplayDecoder.Decode(opts.ReplayPath); if (replay.Mods == OsuParsers.Enums.Mods.Relax) { return; } } catch (Exception) { Console.WriteLine("Can not parse Replay " + opts.ReplayPath); return; } } var associated = new AssociatedBeatmap(beatmap, replay); Console.WriteLine("Aim: {0:R}", associated.GetAimPrecision()); Console.WriteLine("Acc: {0:R}", associated.GetAccPrecision()); return; }
public async Task SubmitScore(CommandContext commandContext) { DiscordMessage msg = await commandContext.Channel.GetMessageAsync(commandContext.Message.Id); logger.LogInformation($"DM {msg.Author}: {msg.Content} : {msg.Attachments.Count}"); WAVMemberCompitInfo compitInfo = wavMembers.GetCompitInfo(commandContext.Member.Id); if (compitInfo.NonGrata) { await commandContext.RespondAsync("Извините, но вы не можете принять участие в данном конкурсе, т.к. внесены в черный список."); return; } if (compitInfo.ProvidedScore) { await commandContext.RespondAsync("Вы уже отправили скор."); return; } if (msg.Attachments.Count == 0) { await commandContext.RespondAsync("Вы не прикрепили к сообщению никаких файлов."); return; } if (msg.Attachments.Count > 1) { await commandContext.RespondAsync("К сообщению можно прикрепить только один файл."); return; } DiscordAttachment attachment = msg.Attachments.First(); if (!attachment.FileName.EndsWith("osr")) { await commandContext.RespondAsync("Файл не является реплеем."); return; } Replay replay = null; try { string fileName = $"{DateTime.Now.Ticks}-{attachment.FileName}"; webClient.DownloadFile(attachment.Url, $"downloads/{fileName}"); replay = ReplayDecoder.Decode($"downloads/{fileName}"); sheduler.AddFileDeleteTask(fileName); } catch (Exception e) { logger.LogCritical(e, "Exception while parsing score"); } if ((int)replay.Mods != 0) { const int b = (int)(OsuParsers.Enums.Mods.NoFail | OsuParsers.Enums.Mods.Perfect | OsuParsers.Enums.Mods.SuddenDeath); if (((int)replay.Mods | b) != b) { await commandContext.RespondAsync("Мы не можем принять данный скор по причине того, что он поставлен с запрещенными на W.w.W модами. \nРазрешенные на W.w.W моды - `NF`, `SD`, `PF`\nСкор система: V1"); return; } } DiscordMember member = await guild.GetMemberAsync(msg.Author.Id); string category = member.Roles.Select(x => x.Name) .FirstOrDefault((x) => { foreach (var xx in (new string[] { "beginner", "alpha", "beta", "gamma", "delta", "epsilon" })) if (x.Contains(xx)) return true; return false; }); StringBuilder sb = new StringBuilder(); sb.AppendLine($"Osu nickname: `{replay.PlayerName}`"); sb.AppendLine($"Discord nickname: `{msg.Author.Username}`"); sb.AppendLine($"Score: `{replay.ReplayScore:N0}`"); // Format: 123456789 -> 123 456 789 sb.AppendLine($"Category: `{category ?? "No category"}`"); sb.AppendLine($"Mods: `{utils.ModsToString((WAV_Osu_NetApi.Bancho.Models.Enums.Mods)replay.Mods)}`"); DiscordEmbedBuilder embed = new DiscordEmbedBuilder().WithAuthor(msg.Author.Username, iconUrl: msg.Author.AvatarUrl) .WithTitle($"Added replay {DateTime.Now.ToShortDateString()} {DateTime.Now.ToShortTimeString()}") .WithUrl(attachment.Url) .WithDescription(sb.ToString()) .AddField("OSR Link:", attachment.Url) .AddField("File name:", $"`{attachment.FileName}`") .WithTimestamp(DateTime.Now); await wavScoresChannel.SendMessageAsync(embed: embed); await commandContext.RespondAsync("Ваш скор был отправлен на рассмотрение. Спасибо за участие!"); }