Skip to content

Commit

Permalink
Merge pull request #1 from archieyates/new-features-branch
Browse files Browse the repository at this point in the history
Updated StatTracker to version 1.4.0.0
  • Loading branch information
archieyates authored Jun 10, 2023
2 parents c48849b + 4778033 commit 4f61881
Show file tree
Hide file tree
Showing 8 changed files with 1,228 additions and 268 deletions.
4 changes: 2 additions & 2 deletions StatTracker/src/StatTracker/Boss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public Boss()
Deaths = 0;
}
}
public class BossContainer
public class LegacyBossContainer
{
public Boss[] Bosses { get; set; }
public List<Boss> Bosses { get; set; } = new List<Boss>();
}
}
6 changes: 4 additions & 2 deletions StatTracker/src/StatTracker/Playthrough.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class Playthrough
public string Status { get; set; }
public string VOD { get; set; }
public string Playtime { get; set; }
public List<Boss> Bosses { get; set; }

public Playthrough()
{
Expand All @@ -17,10 +18,11 @@ public Playthrough()
Status = "Scheduled";
Deaths = 0;
Sessions = 0;
Bosses = new List<Boss>();
}
}
public class PlaythroughContainer
public class LegacyPlaythroughContainer
{
public Playthrough[] Playthroughs { get; set; }
public List<Playthrough> Playthroughs { get; set; } = new List<Playthrough>();
}
}
10 changes: 5 additions & 5 deletions StatTracker/src/StatTracker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ static void Main(string[] args)
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("{0} v{1}", appName, version);

// Load Settings
LoadSettings();

// Check for a version update
VersionCheck();

// Check for any missing data
CheckMissingDirectories();

// Load Settings
LoadSettings();

Console.ResetColor();
// The reader is what handles the input
Reader reader = new Reader();
Expand All @@ -40,7 +40,7 @@ private static void CheckMissingDirectories()
{
Tuple.Create("Stats", System.AppDomain.CurrentDomain.BaseDirectory + "Stats"),
Tuple.Create("Deaths", System.AppDomain.CurrentDomain.BaseDirectory + "Stats\\Deaths"),
Tuple.Create("Bosses", System.AppDomain.CurrentDomain.BaseDirectory + "Stats\\Bosses")
Tuple.Create("Playthroughs", System.AppDomain.CurrentDomain.BaseDirectory + "Stats\\Playthroughs")
};

foreach(var dir in dirs)
Expand Down Expand Up @@ -87,7 +87,7 @@ private static void VersionCheck()
}
private static void LoadSettings()
{
string fileName = "Settings.json";
string fileName = "Stats\\Settings.json";

// Create the file if it doesn't exist
if (!File.Exists(fileName))
Expand Down
84 changes: 36 additions & 48 deletions StatTracker/src/StatTracker/Reader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ private void InitFunctionData()
{"settings", Tuple.Create(new List<string>(){"settings"},"Modify the settings file", Settings) },
{"++", Tuple.Create(new List<string>(){ "++"},"Increment the death count shortcut", AddDeath) },
{"--", Tuple.Create(new List<string>(){ "--"},"Decrement the death count shortcut", SubtractDeath) },
{"++br", Tuple.Create(new List<string>(){"++br"},"Increment the death count without counting the boss shortcut", AddBossRunDeath) },
{"--br", Tuple.Create(new List<string>(){"--br"},"Decrement the death count without counting the boss shortcut", SubtractBossRunDeath) },
{"help", Tuple.Create(new List<string>(){ "help", "commands"},"List help", Help) }
};

Expand All @@ -84,8 +86,11 @@ private void InitFunctionData()
{"new", Tuple.Create(new List<string>(){"new"},"Create a new boss (sets to current)", NewBoss) },
{"list", Tuple.Create(new List<string>(){"list"},"List all the bosses for this playthrough", ListBoss) },
{"current", Tuple.Create(new List<string>(){"current"},"Set the current boss", SetCurrentBoss) },
{"unset", Tuple.Create(new List<string>(){"unset"},"Unset the current boss", UnsetCurrentBoss) },
{"defeat", Tuple.Create(new List<string>(){"defeat"},"Mark current boss as defeated", DefeatBoss) },
{"delete", Tuple.Create(new List<string>(){ "delete"},"Delete a specified boss", DeleteBoss) },
{"next", Tuple.Create(new List<string>(){ "next"},"Set the next undefeated boss as current", NextBoss) },
{"previous", Tuple.Create(new List<string>(){ "prev"},"Set the previous undefeated boss as current", PreviousBoss) },
{"esc", Tuple.Create(new List<string>(){ "esc"},"Return back to main", Return) }
};

Expand All @@ -94,6 +99,8 @@ private void InitFunctionData()
{
{"add", Tuple.Create(new List<string>(){"add", "++"},"Increment the death count", AddDeath) },
{"subtract", Tuple.Create(new List<string>(){ "subtract", "--"},"Decrement the death count", SubtractDeath) },
{"bradd", Tuple.Create(new List<string>(){"bradd", "++br"},"Increment the death count without counting the boss", AddBossRunDeath) },
{"brsubtract", Tuple.Create(new List<string>(){ "brsubtract", "--br"},"Decrement the death count without counting the boss", SubtractBossRunDeath) },
{"esc", Tuple.Create(new List<string>(){ "esc"},"Return back to main", Return) }
};

Expand Down Expand Up @@ -215,28 +222,7 @@ private void NewGame()
// If we're auto-generating the lookup then remove all the spaces from the game name
if (Program.Settings.AutoGenerateLookup)
{
bool lookupInvalid = true;
string gameNameShortened = Regex.Replace(gameName, "[^0-9a-zA-Z]+", "").ToLower();
string potentialLookup = gameNameShortened;
int index = 1;

do
{
// If the lookup doesn't exist then bail out
if (Manager.Playthroughs.Find(p => p.Lookup == potentialLookup) == null)
{
lookupInvalid = false;
}
else
{
// Otherwise increase the number on the end and try again
index++;
potentialLookup = gameNameShortened + index.ToString();
}

} while (lookupInvalid);

lookup = potentialLookup;
lookup = Manager.GeneratePlaythroughLookup(gameName);
}
else
{
Expand Down Expand Up @@ -305,28 +291,7 @@ private void NewBoss()
// If we're auto-generating the lookup then remove all the spaces from the game name
if (Program.Settings.AutoGenerateLookup)
{
bool lookupInvalid = true;
string bossNameShortened = Regex.Replace(bossName, "[^0-9a-zA-Z]+", "").ToLower();
string potentialLookup = bossNameShortened;
int index = 1;

do
{
// If the lookup doesn't exist then bail out
if (Manager.Bosses.Find(b => b.Lookup == potentialLookup) == null)
{
lookupInvalid = false;
}
else
{
// Otherwise increase the number on the end and try again
index++;
potentialLookup = bossNameShortened + index.ToString();
}

} while (lookupInvalid);

lookup = potentialLookup;
lookup = Manager.GenerateBossLookup(bossName);
}
else
{
Expand All @@ -336,7 +301,7 @@ private void NewBoss()
lookup = Regex.Replace(lookup, "[^0-9a-zA-Z]+", "");

// Check this playthrough doesn't already exist
if (Manager.Bosses.Find(b => b.Lookup == lookup) != null)
if (Manager.GetCurrentPlaythrough().Bosses.Find(b => b.Lookup == lookup) != null)
{
Program.WriteLine(ConsoleColor.Red, "{0} already in use", lookup);
return;
Expand All @@ -350,7 +315,7 @@ private void ListBoss()
{
// List some boss data
Console.ForegroundColor = ConsoleColor.Green;
foreach (Boss boss in Manager.Bosses)
foreach (Boss boss in Manager.GetCurrentPlaythrough().Bosses)
{
Console.WriteLine("{0} | {1} | {2} | {3}", boss.Lookup, boss.Name, boss.Status, boss.Deaths);
}
Expand All @@ -364,6 +329,11 @@ private void SetCurrentBoss()
// Manager handles the actual data
Manager.SetCurrentBoss(lookup);
}
private void UnsetCurrentBoss()
{
// Manager handles the actual data
Manager.SetCurrentBoss(String.Empty);
}
private void DefeatBoss()
{
// Manager handles the actual data
Expand All @@ -378,15 +348,33 @@ private void DeleteBoss()
// Manager handles the actual data
Manager.DeleteBoss(lookup);
}
private void NextBoss()
{
Manager.NextBoss();
}
private void PreviousBoss()
{
Manager.PreviousBoss();
}
private void AddDeath()
{
// Manager handles the actual data
Manager.AddDeath();
Manager.AddDeath(true);
}
private void SubtractDeath()
{
// Manager handles the actual data
Manager.SubtractDeath();
Manager.SubtractDeath(true);
}
private void AddBossRunDeath()
{
// Manager handles the actual data
Manager.AddDeath(false);
}
private void SubtractBossRunDeath()
{
// Manager handles the actual data
Manager.SubtractDeath(false);
}
private void EditSetting()
{
Expand Down
2 changes: 1 addition & 1 deletion StatTracker/src/StatTracker/StatTracker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>disable</Nullable>
<Title>Stream Stat Tracker</Title>
<PackageId>StreamStatTracker</PackageId>
<AssemblyVersion>1.3.0.0</AssemblyVersion>
<AssemblyVersion>1.4.0.0</AssemblyVersion>
</PropertyGroup>

</Project>
Loading

0 comments on commit 4f61881

Please sign in to comment.