Created
February 25, 2021 13:42
-
-
Save stulentsev/0de7b06e47634c11e901817123aca94c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using FortniteReplayReader; | |
using Unreal.Core.Models.Enums; | |
using System.Threading.Tasks; | |
using Fortnite_API; | |
using Fortnite_API.Objects.V1; | |
using FortniteReplayReader.Models; | |
using System.CommandLine; | |
using System.CommandLine.Invocation; | |
using System.IO; | |
namespace w0lfdude | |
{ | |
class FNReplayParser | |
{ | |
private static async Task Main(string[] args) | |
{ | |
var rootCommand = new RootCommand | |
{ | |
new Option<bool>( | |
new[] {"--detailed", "-d"}, | |
"Show ID, platform, placement and eliminations."), | |
new Option<bool>( | |
new[] {"--verbose", "-v"}, | |
"Show stats for solo, duos and squads matches (Elims,K/D and matches played)."), | |
new Argument<string>( | |
"replayFile", | |
"Replay file to parse.") | |
}; | |
rootCommand.Description = "Fortnite Replay Parser"; | |
// Note that the parameters of the handler method are matched according to the names of the options | |
rootCommand.Handler = CommandHandler.Create<bool, bool, string>(async (detailed, verbose, replayFile) => { | |
var reader = new ReplayReader(parseMode: ParseMode.Full); | |
var replay = reader.ReadReplay(replayFile); | |
var count_player = 0; | |
var count_bot = 0; | |
var pPSN = 0; | |
var pXBL = 0; | |
var pWIN = 0; | |
var pSWT = 0; | |
var pIOS = 0; | |
var pMAC = 0; | |
var pAND = 0; | |
var pMISC = 0; | |
var pPS5 = 0; | |
var pXSX = 0; | |
var api = new FortniteApi(); | |
var bDetailed = detailed; | |
var bVerbose = verbose; | |
foreach (var playerData in replay.PlayerData) | |
{ | |
if (!string.IsNullOrEmpty(playerData.EpicId)) | |
{ | |
var AccountID = playerData.EpicId.ToLower(); | |
count_player++; | |
switch (playerData.Platform) | |
{ | |
case "PSN": | |
pPSN++; | |
break; | |
case "XBL": | |
pXBL++; | |
break; | |
case "WIN": | |
pWIN++; | |
break; | |
case "SWT": | |
pSWT++; | |
break; | |
case "IOS": | |
pIOS++; | |
break; | |
case "MAC": | |
pMAC++; | |
break; | |
case "AND": | |
pAND++; | |
break; | |
case "PS5": | |
pPS5++; | |
break; | |
case "XSX": | |
pXSX++; | |
break; | |
default: | |
pMISC++; | |
break; | |
} | |
if (bVerbose) { | |
var statsV2V1 = await api.V1.Stats.GetBrV2Async(x => | |
{ | |
x.AccountId = AccountID; | |
x.ImagePlatform = BrStatsV2V1ImagePlatform.All; | |
}); | |
string playername = "NONE"; | |
long stats_solo_win = 0; | |
double stats_solo_kd = 0; | |
long stats_solo_matches = 0; | |
long stats_duo_win = 0; | |
double stats_duo_kd = 0; | |
long stats_duo_matches = 0; | |
long stats_squad_win = 0; | |
double stats_squad_kd = 0; | |
long stats_squad_matches = 0; | |
if (statsV2V1.IsSuccess) | |
{ | |
playername = statsV2V1.Data.Account.Name; | |
if (statsV2V1.Data.Stats.All.Solo != null) | |
{ | |
stats_solo_win = statsV2V1.Data.Stats.All.Solo.Wins; | |
stats_solo_kd = statsV2V1.Data.Stats.All.Solo.Kd; | |
stats_solo_matches = statsV2V1.Data.Stats.All.Solo.Matches; | |
} | |
if (statsV2V1.Data.Stats.All.Duo != null) | |
{ | |
stats_duo_win = statsV2V1.Data.Stats.All.Duo.Wins; | |
stats_duo_kd = statsV2V1.Data.Stats.All.Duo.Kd; | |
stats_duo_matches = statsV2V1.Data.Stats.All.Duo.Matches; | |
} | |
if (statsV2V1.Data.Stats.All.Squad != null) | |
{ | |
stats_squad_win = statsV2V1.Data.Stats.All.Squad.Wins; | |
stats_squad_kd = statsV2V1.Data.Stats.All.Squad.Kd; | |
stats_squad_matches = statsV2V1.Data.Stats.All.Squad.Matches; | |
} | |
} | |
Console.WriteLine($"{AccountID} {playerData.Platform} {playerData.Placement} ({playerData.Kills}) [ ({playername}) {stats_solo_win} {stats_solo_kd} {stats_solo_matches}, " + | |
$" {stats_duo_win} {stats_duo_kd} {stats_duo_matches}, {stats_squad_win} {stats_squad_kd} {stats_squad_matches} ]"); | |
} | |
if (bDetailed) { | |
Console.WriteLine($"{AccountID} {playerData.Platform} {playerData.Placement} ({playerData.Kills})"); | |
} | |
} | |
if (!string.IsNullOrEmpty(playerData.BotId)) | |
{ | |
count_bot++; | |
} | |
} | |
Console.WriteLine($"Humans: {count_player}, Bots: {count_bot}"); | |
Console.WriteLine($"PSN: {pPSN}, PS5: {pPS5}, XBL: {pXBL}, XSX: {pXSX}, WIN: {pWIN}, SWT: {pSWT}, IOS: {pIOS}, MAC: {pMAC}, AND: {pAND}, MISC: {pMISC}"); | |
}); | |
// Parse the incoming args and invoke the handler | |
await rootCommand.InvokeAsync(args); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net5.0</TargetFramework> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="Fortnite-API-Wrapper" Version="2.1.0" /> | |
<PackageReference Include="FortniteReplayReader" Version="1.1.2" /> | |
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20574.7" /> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment