Skip to content

Commit

Permalink
Update 1.7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DarwinBaker committed Jan 6, 2024
1 parent 964f06a commit 9c65258
Show file tree
Hide file tree
Showing 136 changed files with 6,108 additions and 671 deletions.
188 changes: 176 additions & 12 deletions AATool/AATool.csproj

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions AATool/Configuration/TrackingConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class TrackingConfig : Config
[JsonProperty] public readonly Setting<string> LastSession = new (string.Empty);
[JsonProperty] public readonly Setting<string> LastPlayer = new (string.Empty);
[JsonProperty] public readonly Setting<Uuid> LastUuid = new (Uuid.Empty);
[JsonProperty] public readonly Setting<string> CurrentRunnerProfileId = new (string.Empty);
[JsonProperty] public readonly Setting<string> CurrentRunnerProfileName = new (string.Empty);

[JsonProperty] public readonly Setting<string> GameCategory = new ("All Advancements");
[JsonProperty] public readonly Setting<string> GameVersion = new ("1.16");
Expand All @@ -34,6 +36,10 @@ public class TrackingConfig : Config

[JsonProperty] public readonly Setting<DateTime> LastOpenedAllBlocks = new (default);

[JsonIgnore]
public string CurrentRunnerProfileNameOrId => !string.IsNullOrEmpty(this.CurrentRunnerProfileId)
? this.CurrentRunnerProfileId : this.CurrentRunnerProfileName;

[JsonIgnore]
public bool WatchActiveInstance => !this.UseSftp
&& (this.Source == TrackerSource.ActiveInstance || this.AutoDetectVersion || Tracker.Category is AllDeaths);
Expand Down
149 changes: 88 additions & 61 deletions AATool/Data/Credits.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
using System;
using System.Collections.Generic;
using System.IO;
using AATool.Data.Speedrunning;
using AATool.Net;
using AATool.Net.Requests;
using AATool.Winforms.Controls;

namespace AATool.Data
{
public static class Credits
{
static bool SupporterSheetLoaded;

public const string Developer = "developer";
public const string Dedication = "special dedication";
public const string BetaTester = "beta testers";
Expand Down Expand Up @@ -49,56 +54,21 @@ public static class Credits

private static bool Initialized = false;

private static Dictionary<string, Credit> ByName = new Dictionary<string, Credit>();
private static Dictionary<Uuid, Credit> ByUuid = new Dictionary<Uuid, Credit>();
public static HashSet<Credit> All { get; private set; } = new();

private static Dictionary<string, Credit> ByName = new();
private static Dictionary<Uuid, Credit> ByUuid = new();

public static readonly HashSet<Credit> All = new ()
public static readonly HashSet<Credit> Special = new ()
{
new (Developer, "CTM", new Uuid("60bddec7-939c-4753-a898-cffa33134a4d"), "https://www.patreon.com/_ctm"),
new (Dedication, "Wroxy"),

new (BetaTester, "Elysaku", new Uuid("b2fcb273-9886-4a9b-bd7f-e005816fb7b7"), "https://www.twitch.tv/elysaku"),
new (BetaTester, "Churro :3", "https://www.instagram.com/theelysaku/"),

new (NetheriteTier, "greasyw00t", new Uuid("1da9854f-f89a-4607-9d52-d0ef7a18f7bf")),
new (NetheriteTier, "MathoX", new Uuid("4c8b46f2-df0c-4417-9bc3-12a025fcca85")),
new (NetheriteTier, "yuukster", new Uuid("5b7fbb82-62df-4f0f-993a-e2747c2c5530")),
new (NetheriteTier, "Toshio", new Uuid("71c35984-2091-4b64-9601-6e7145c9dffe")),
new (NetheriteTier, "Feinberg", new Uuid("9a8e24df-4c85-49d6-96a6-951da84fa5c4")),
new (NetheriteTier, "PeteZahHutt", new Uuid("7ac3c39f-23d5-472a-a7c9-24798265fa15")),
new (NetheriteTier, "Deadpool", new Uuid("899c63ac-6590-46c0-b77c-4dae1543f707")),
new (NetheriteTier, "merpmerp", new Uuid("fc357f37-ebbb-4687-971f-df8016b41a6f")),
new (NetheriteTier, "Oliver", new Uuid("6174765b-7158-4d18-af89-4692b2704ae8")),
new (NetheriteTier, "DCMii", new Uuid("3d71114e-4d3d-469b-8a2c-2aeea4df1e86")),

new (DiamondTier, "NiceTwice", new Uuid("e43dad54-4b24-4da9-b690-a12fdc8626dc")),
new (DiamondTier, "Cube1337x", new Uuid("1ae14cb9-6a2f-4357-a71e-fac6f7012b59")),

new (DiamondTier, "Nex", new string[] { "Ravager", "Magneton" },
new Uuid[] { "cd74c07d-eb62-4874-a827-df5f30fbb3d1", "738afed3-40da-443c-ac43-50b5f16409ef" }),

new (DiamondTier, "HAPTlCx", new Uuid("b7860d3b-e24e-4f75-a0c7-5697ef592a80")),
new (DiamondTier, "Soren"),
new (DiamondTier, "macus", new Uuid("d0193deb-f13c-449d-9a48-5a0ed38528d8")),

new (GoldTier, "Antoine", new Uuid("6350caba-e20b-4097-a384-931b76dca501")),
new (GoldTier, "TheSwordElf"),
new (GoldTier, "MeisterMaki", new Uuid("fd21bbc7-c59c-41f7-ba86-5fa68dcd41bf")),
new (GoldTier, "Infernalord", new Uuid("fbea5a5f-6fbb-478b-af1d-f433df4903ed")),
new (GoldTier, "MoleyG", new Uuid("fa1bec35-0585-46c9-8f92-79f8be7cf9bc")),
new (GoldTier, "AutomattPL", new Uuid("fa61606e-8131-484c-8dee-506d1ff9a8dc")),
new (GoldTier, "T_Wagz", new Uuid("1351bf1c-84df-408d-9499-f67c45abb3e2")),
new (GoldTier, "Colin_Henry", new Uuid("c32aefa5-ea67-479e-bee6-13174ceb2769")),
new (GoldTier, "NotValik"),
new (GoldTier, "Switch", new Uuid("b24da04f-8a72-4f28-a7cc-b8cbdfa57991")),
new (GoldTier, "Melissa", new Uuid("2482ebed-44c7-4a95-81f0-853ef3a55928")),
new (GoldTier, "pneguin"),
new (GoldTier, "Tompas"),
new (GoldTier, "Xerionix", new Uuid("2e0a64c0-bf62-4e41-91b4-be1d39d10324")),
new (GoldTier, "Toomm"),
new (Developer, "", "CTM", new Uuid("60bddec7-939c-4753-a898-cffa33134a4d"), "https://www.patreon.com/_ctm"),
new (Dedication, "", "Wroxy"),

new (BetaTester, "", "Elysaku", new Uuid("b2fcb273-9886-4a9b-bd7f-e005816fb7b7"), "https://www.twitch.tv/elysaku"),
new (BetaTester, "", "Churro :3", "https://www.instagram.com/theelysaku/"),
};

private static void InitializeLookups()
private static void EnsureLookupsInitialized()
{
if (Initialized)
return;
Expand All @@ -116,7 +86,7 @@ private static void InitializeLookups()

public static bool TryGet(Uuid player, out Credit credit)
{
InitializeLookups();
EnsureLookupsInitialized();
return ByUuid.TryGetValue(player, out credit);
}

Expand All @@ -126,44 +96,101 @@ public static bool TryGet(string name, out Credit credit)
if (string.IsNullOrEmpty(name))
return false;

InitializeLookups();
EnsureLookupsInitialized();
return ByName.TryGetValue(name.ToLower(), out credit);
}

internal static void Initialize()
{
TryLoadCached();
new SpreadsheetRequest("supporters", Paths.Web.SupporterSheet).EnqueueOnce();
}

public static bool SyncSheet(string csv)
{
if (SupporterSheet.TryParse(csv, out SupporterSheet sheet))
{
sheet.GetCredits(out HashSet<Credit> all);
All = all;
SupporterSheetLoaded = true;
sheet.SaveToCache();
}
return SupporterSheetLoaded;
}

private static bool TryLoadCached()
{
string path = Paths.System.SupportersFile;
if (File.Exists(path))
{
try
{
string csv = File.ReadAllText(path);
if (SupporterSheet.TryParse(csv, out SupporterSheet sheet))
{
sheet.GetCredits(out HashSet<Credit> all);
All = all;
return true;
}
}
catch
{
//couldn't read cached supporters, move on
}
}
return false;
}
}

public struct Credit
{
public string Name;
public string Role;
public string HighestRole;
public string CurrentRole;
public string Link;
public string[] AltNames;
public Uuid[] Uuids;
public List<string> AltNames;
public List<Uuid> Uuids;

public readonly bool Active => !string.IsNullOrEmpty(this.CurrentRole);

public Credit(string role, string name, Uuid? uuid = null, string link = "")
public Credit(string highestRole, string currentRole, string name, Uuid? uuid = null, string link = "")
{
this.Name = name;
this.Role = role;
this.Uuids = new[] { uuid ?? Uuid.Empty };
this.AltNames = new string[0];
this.HighestRole = RoleKey(highestRole);
this.CurrentRole = RoleKey(currentRole);
this.Uuids = new() { uuid ?? Uuid.Empty };
this.AltNames = new();
this.Link = link;
}

public Credit(string role, string name, string link)
public Credit(string highestRole, string currentRole, string name, string link)
{
this.Name = name;
this.Role = role;
this.Uuids = new[] { Uuid.Empty };
this.AltNames = new string[0];
this.HighestRole = RoleKey(highestRole);
this.CurrentRole = RoleKey(currentRole);
this.Uuids = new() { Uuid.Empty };
this.AltNames = new();
this.Link = link;
}

public Credit(string role, string name, string[] names, Uuid[] uuids)
public Credit(string highestRole, string currentRole, string name, List<string> names, List<Uuid> uuids)
{
this.Name = name;
this.Role = role;
this.HighestRole = RoleKey(highestRole);
this.CurrentRole = RoleKey(currentRole);
this.Uuids = uuids;
this.AltNames = names;
this.Link = string.Empty;
}

private static string RoleKey(string tier)
{
return tier switch {
"Netherite" => Credits.NetheriteTier,
"Diamond" => Credits.DiamondTier,
"Gold" => Credits.GoldTier,
_ => tier
};
}
}
}
53 changes: 53 additions & 0 deletions AATool/Data/Speedrunning/AllVersionsRun.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System;

namespace AATool.Data.Speedrunning
{
internal class AllVersionsRun : Run
{
public string Range { get; set; }
public bool Hardcore { get; set; }
public bool NoF3 { get; set; }

public static new bool TryParse(LeaderboardSheet sheet, int rowIndex, string gameVersion, out Run pb)
{
pb = null;
try
{
string[] row = sheet.Rows[rowIndex];
//required columns
if (!sheet.TryGetRunner(rowIndex, out string runner))
return false;

//optional columns
sheet.TryGetRta(rowIndex, out TimeSpan rta);
sheet.TryGetDate(rowIndex, out DateTime date);
sheet.TryGetRank(rowIndex, out int rank);

sheet.TryGetRange(rowIndex, out string range);
sheet.TryGetIsNoF3(rowIndex, out bool noF3);
sheet.TryGetIsHardcore(rowIndex, out bool hardcore);

if (!sheet.TryGetLink(rowIndex, out string link))
Leaderboard.AALinks.TryGetValue((runner, date), out link);

_= Version.TryParse(gameVersion, out Version version);

pb = new AllVersionsRun() {
GameVersion = version,
RealTime = rta,
Date = date,
Runner = runner,
Link = link,
Range = range,
NoF3 = noF3,
Hardcore = hardcore,
};
return true;
}
catch
{
return false;
}
}
}
}
55 changes: 55 additions & 0 deletions AATool/Data/Speedrunning/HardcoreStreak.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;

namespace AATool.Data.Speedrunning
{
internal class HardcoreStreak : Run
{
public string Runs { get; set; }
public string Deaths { get; set; }
public int BestStreak { get; set; }
public bool OnBestStreak { get; set; }

public static bool TryParse(LeaderboardSheet sheet, int rowIndex, string gameVersion, out HardcoreStreak pb)
{
pb = null;
try
{
string[] row = sheet.Rows[rowIndex];
//required columns
if (!sheet.TryGetRunner(rowIndex, out string runner))
return false;

//optional columns
sheet.TryGetIgt(rowIndex, out TimeSpan igt);
sheet.TryGetDate(rowIndex, out DateTime date);
sheet.TryGetRank(rowIndex, out int rank);
sheet.TryGetRuns(rowIndex, out string runs);
sheet.TryGetDeaths(rowIndex, out string deaths);
sheet.TryGetStreak(rowIndex, out int streak);
sheet.TryGetOnBestStreak(rowIndex, out bool onBestStreak);

if (!sheet.TryGetLink(rowIndex, out string link))
Leaderboard.AALinks.TryGetValue((runner, date), out link);

_= Version.TryParse(gameVersion, out Version version);

pb = new HardcoreStreak() {
GameVersion = version,
InGameTime = igt,
Date = date,
Runner = runner,
Link = link,
Runs = runs,
Deaths = deaths,
BestStreak = streak,
OnBestStreak = onBestStreak,
};
return true;
}
catch
{
return false;
}
}
}
}
Loading

0 comments on commit 9c65258

Please sign in to comment.