Skip to content

Testing, fixing, adding #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: bonus-timing
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions src/ST-Map/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,20 @@ GROUP BY MapTimes.type
this.ConnectedMapTimes.Clear();
while (mapWrData.Read())
{
if (mapWrData.GetInt32("type") > 0)
if (mapWrData.GetInt32("type") == 1)
{
this.BonusWR[mapWrData.GetInt32("type")][style].ID = mapWrData.GetInt32("id"); // WR ID for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].Ticks = mapWrData.GetInt32("run_time"); // Fastest run time (WR) for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].Type = mapWrData.GetInt32("type"); // Bonus type (0 = map, 1+ = bonus index)
this.BonusWR[mapWrData.GetInt32("type")][style].StartVelX = mapWrData.GetFloat("start_vel_x"); // Fastest run start velocity X for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].StartVelY = mapWrData.GetFloat("start_vel_y"); // Fastest run start velocity Y for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].StartVelZ = mapWrData.GetFloat("start_vel_z"); // Fastest run start velocity Z for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].EndVelX = mapWrData.GetFloat("end_vel_x"); // Fastest run end velocity X for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].EndVelY = mapWrData.GetFloat("end_vel_y"); // Fastest run end velocity Y for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].EndVelZ = mapWrData.GetFloat("end_vel_z"); // Fastest run end velocity Z for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].RunDate = mapWrData.GetInt32("run_date"); // Fastest run date for the Map and Style combo
this.BonusWR[mapWrData.GetInt32("type")][style].Name = mapWrData.GetString("name"); // Fastest run player name for the Map and Style combo
int bonusNum = mapWrData.GetInt32("stage") - 1;
this.BonusWR[bonusNum][style].ID = mapWrData.GetInt32("id"); // WR ID for the Map and Style combo
this.BonusWR[bonusNum][style].Ticks = mapWrData.GetInt32("run_time"); // Fastest run time (WR) for the Map and Style combo
this.BonusWR[bonusNum][style].Type = mapWrData.GetInt32("type"); // Bonus type (0 = map, 1+ = bonus index)
this.BonusWR[bonusNum][style].StartVelX = mapWrData.GetFloat("start_vel_x"); // Fastest run start velocity X for the Map and Style combo
this.BonusWR[bonusNum][style].StartVelY = mapWrData.GetFloat("start_vel_y"); // Fastest run start velocity Y for the Map and Style combo
this.BonusWR[bonusNum][style].StartVelZ = mapWrData.GetFloat("start_vel_z"); // Fastest run start velocity Z for the Map and Style combo
this.BonusWR[bonusNum][style].EndVelX = mapWrData.GetFloat("end_vel_x"); // Fastest run end velocity X for the Map and Style combo
this.BonusWR[bonusNum][style].EndVelY = mapWrData.GetFloat("end_vel_y"); // Fastest run end velocity Y for the Map and Style combo
this.BonusWR[bonusNum][style].EndVelZ = mapWrData.GetFloat("end_vel_z"); // Fastest run end velocity Z for the Map and Style combo
this.BonusWR[bonusNum][style].RunDate = mapWrData.GetInt32("run_date"); // Fastest run date for the Map and Style combo
this.BonusWR[bonusNum][style].Name = mapWrData.GetString("name"); // Fastest run player name for the Map and Style combo
}

else
Expand All @@ -335,7 +336,7 @@ GROUP BY MapTimes.type

// Count completions
Task<MySqlDataReader> completionStats = DB.Query($@"
SELECT MapTimes.type, COUNT(*) as count
SELECT MapTimes.type, MapTimes.stage, COUNT(*) as count
FROM MapTimes
WHERE MapTimes.map_id = {this.ID}
GROUP BY type;
Expand All @@ -346,12 +347,14 @@ FROM MapTimes
{
while (completionStatsResult.Read())
{
if (completionStatsResult.GetInt32("type") > 0)
if (completionStatsResult.GetInt32("type") == 1)
{
// To-do: bonus completion counts
this.BonusCompletions[completionStatsResult.GetInt32("type")][style] = completionStatsResult.GetInt32("count");
this.BonusCompletions[completionStatsResult.GetInt32("stage")][style] = completionStatsResult.GetInt32("count");
}

// Add stage completions

else
{
// Total completions for the map and style - this should maybe be added to PersonalBest class
Expand All @@ -362,7 +365,8 @@ FROM MapTimes
completionStatsResult.Close();

// Get map world record checkpoints
if (this.MapCompletions[style] != 0)
System.Console.WriteLine("Testy Test 2 =====================");
if (this.MapCompletions.ContainsKey(style) && this.MapCompletions[style] != 0)
{
Task<MySqlDataReader> cpReader = DB.Query($"SELECT * FROM `Checkpoints` WHERE `maptime_id` = {this.WR[style].ID};");
MySqlDataReader cpWrData = cpReader.Result;
Expand Down