Skip to content

Commit

Permalink
comments;move stuff around
Browse files Browse the repository at this point in the history
  • Loading branch information
tslashd committed Dec 23, 2023
1 parent 1980ad2 commit bcbec71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/ST-Events/TriggerStartTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,15 @@ internal HookResult OnTriggerStartTouch(DynamicHook handler)
if (player.Stats.PB[0].RunTime <= 0) // Player first ever PersonalBest for the map
{
Server.PrintToChatAll($"{PluginPrefix} {player.Controller.PlayerName} finished the map in {ChatColors.Gold}{player.HUD.FormatTime(player.Timer.Ticks)}{ChatColors.Default} ({player.Timer.Ticks})!");
// player.Controller.PrintToChat($"{PluginPrefix} Congratulations on setting your PB in {ChatColors.Gold}{player.HUD.FormatTime(player.Timer.Ticks)}{ChatColors.Default} ({player.Timer.Ticks})!");
}
else if (player.Timer.Ticks < player.Stats.PB[0].RunTime) // Player beating their existing PersonalBest for the map
{
// player.Controller.PrintToChat($"{PluginPrefix} You beat your PB in {ChatColors.Gold}{player.HUD.FormatTime(player.Timer.Ticks)}{ChatColors.Default} (Old: {ChatColors.BlueGrey}{player.HUD.FormatTime(player.Stats.PB[0].RunTime)}{ChatColors.Default})!");
Server.PrintToChatAll($"{PluginPrefix} {ChatColors.Lime}{player.Profile.Name}{ChatColors.Default} beat their PB in {ChatColors.Gold}{player.HUD.FormatTime(player.Timer.Ticks)}{ChatColors.Default} (Old: {ChatColors.BlueGrey}{player.HUD.FormatTime(player.Stats.PB[0].RunTime)}{ChatColors.Default})!");
}
else // Player did not beat their existing PersonalBest for the map
{
player.Controller.PrintToChat($"{PluginPrefix} You finished the map in {ChatColors.Yellow}{player.HUD.FormatTime(player.Timer.Ticks)}{ChatColors.Default}!");
return HookResult.Continue;
return HookResult.Continue; // Exit here so we don't write to DB
}

if (DB == null)
Expand Down
21 changes: 8 additions & 13 deletions src/ST-Player/PlayerStats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,29 +272,25 @@ internal class PlayerStats
{
// To-Do: Each stat should be a class of its own, with its own methods and properties - easier to work with.
// Temporarily, we store ticks + basic info so we can experiment

public Dictionary<int, PersonalBest> PB { get; set; } = new Dictionary<int, PersonalBest>();

public CurrentRun ThisRun {get; set;} = new CurrentRun(); // This is a CurrenntRun object that tracks the data for the Player's current run

// These account for future style support and a relevant index.
// public int[,] PB {get; set;} = {{0,0}}; // First dimension: style (0 = normal), second dimension: map/bonus (0 = map, 1+ = bonus index)
// public int[,] Checkpoints { get; set; } = { { 0, 0 } }; // First dimension: style (0 = normal), second dimension: checkpoint index
// public int[,] Rank { get; set; } = { { 0, 0 } }; // First dimension: style (0 = normal), second dimension: map/bonus (0 = map, 1+ = bonus index)
public int[,] StagePB { get; set; } = { { 0, 0 } }; // First dimension: style (0 = normal), second dimension: stage index
public int[,] StageRank { get; set; } = { { 0, 0 } }; // First dimension: style (0 = normal), second dimension: stage index

//

public Dictionary<int, PersonalBest> PB { get; set; } = new Dictionary<int, PersonalBest>();
public CurrentRun ThisRun {get; set;} = new CurrentRun(); // This is a CurrenntRun object that tracks the data for the Player's current run
// Initialize PersonalBest for each `style` (e.g., 0 for normal) - this is a temporary solution
// Here we can loop through all available styles at some point and initialize them
public PlayerStats()
{
PB[0] = new PersonalBest(-1, 0, 0, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0);
// Add more styles as needed
}

// This can populate all the `style` stats the player has for the map - currently only 1 style is supported
/// <summary>
/// Loads the player's MapTimes data from the database along with `Rank` for the run.
/// `Checkpoints` are loaded separately.
/// `Checkpoints` are loaded separately because inside the while loop we cannot run queries.
/// This can populate all the `style` stats the player has for the map - currently only 1 style is supported
/// </summary>
public void LoadMapTimesData(int playerId, int mapId, TimerDatabase DB)
{
Expand Down Expand Up @@ -329,8 +325,7 @@ public void LoadMapTimesData(int playerId, int mapId, TimerDatabase DB)
#if DEBUG
Console.WriteLine($"CS2 Surf DEBUG >> internal class PlayerStats -> LoadMapTimesData -> PlayerStats.PB (ID {PB[style].ID}) loaded from DB.");
#endif
}

}
}
playerStats.Close();
}
Expand Down

0 comments on commit bcbec71

Please sign in to comment.