Skip to content
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

add stats to each snapshot; #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion game_client/Assets/Scripts/3_Main/_ReplaySystem/Recorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ private void CreateSnapshot()
{
var snapshot = new Snapshot
{
Position = new Position(Helper.InvertY(player!.transform.position))
Position = new Position(Helper.InvertY(player!.transform.position)),
SessionStatisticsPlain = SessionStatistics.Instance!.GetPlainCopy()

};
_snapshots!.Add(snapshot);
}
Expand Down
2 changes: 2 additions & 0 deletions game_client/Assets/Scripts/3_Main/_ReplaySystem/Snapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
public class Snapshot
{
public Position Position { get; set; }

public SessionStatisticsPlain SessionStatisticsPlain { get; set; }
}
}
42 changes: 28 additions & 14 deletions rest_service/Controllers/RecordingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ public async Task<IActionResult> PostRecording([FromBody] RecordingRequest recor
X = dto.Position.X,
Y = dto.Position.Y,
Z = dto.Position.Z
},
SessionStatisticsPlain = new SessionStatisticsPlain
{
Score = dto.SessionStatisticsPlain.Score,
DamageDone = dto.SessionStatisticsPlain.DamageDone,
BulletsFired = dto.SessionStatisticsPlain.BulletsFired,
PelletsDestroyedLarge = dto.SessionStatisticsPlain.PelletsDestroyedLarge,
PelletsDestroyedMedium = dto.SessionStatisticsPlain.PelletsDestroyedMedium,
PelletsDestroyedSmall = dto.SessionStatisticsPlain.PelletsDestroyedSmall,
PowerUpBulletDamageCollected = dto.SessionStatisticsPlain.PowerUpBulletDamageCollected,
PowerUpBulletSpeedCollected = dto.SessionStatisticsPlain.PowerUpBulletSpeedCollected,
PowerUpPlayerSpeedCollected = dto.SessionStatisticsPlain.PowerUpPlayerSpeedCollected
}
}).ToList()
};
Expand All @@ -69,7 +81,9 @@ public async Task<IActionResult> PostRecording([FromBody] RecordingRequest recor
newRecording.StatsVector
});

} catch (Exception) {
}
catch (Exception)
{
// Favor persisting Recording over setting vectors
}

Expand Down Expand Up @@ -97,9 +111,9 @@ public async Task<IActionResult> PostRecording([FromBody] RecordingRequest recor
catch (MultiplePlayersFoundException)
{
return BadRequest(new
{ Message = $"The player '{newRecording.Player.Name}' exists multiple times." });
{ Message = $"The player '{newRecording.Player.Name}' exists multiple times." });
}
catch(Exception e)
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
Expand Down Expand Up @@ -129,11 +143,11 @@ private async Task AddLocation(Recording recording)
switch (events.Count)
{
case 1:
{
var eventLocation = events[0].Location;
recording.Location = eventLocation;
break;
}
{
var eventLocation = events[0].Location;
recording.Location = eventLocation;
break;
}
case 0:
throw new EventNotFoundException();
default:
Expand All @@ -149,11 +163,11 @@ private async Task AddPlayer(Recording recording)
switch (players.Count)
{
case 1:
{
recording.Player.Name = players[0].Name;
recording.Player.Location = players[0].Location;
break;
}
{
recording.Player.Name = players[0].Name;
recording.Player.Location = players[0].Location;
break;
}
case 0:
throw new PlayerNotFoundException();
default:
Expand Down Expand Up @@ -292,7 +306,7 @@ public async Task<List<SimilarRecordingResponse>> SimilarBySpeed([FromQuery] Pla

return response;
}

[HttpGet("similarByAcceleration", Name = "GetSimilarByAcceleration")]
public async Task<List<SimilarRecordingResponse>> SimilarByAcceleration([FromQuery] PlayerRequest playerRequest)
{
Expand Down
2 changes: 2 additions & 0 deletions rest_service/Dtos/RequestObjects/SnapshotRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ namespace RestService.Dtos.RequestObjects;
public class SnapshotRequest
{
public Position? Position { get; set; }

public SessionStatisticsPlain? SessionStatisticsPlain { get; set; }
}
2 changes: 2 additions & 0 deletions rest_service/Entities/Snapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ namespace RestService.Entities;
public class Snapshot
{
public Position Position { get; set; }

public SessionStatisticsPlain? SessionStatisticsPlain { get; set; }
}
Binary file modified website/wwwroot/Build/build_web.data.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion website/wwwroot/Build/build_web.framework.js

Large diffs are not rendered by default.

Binary file modified website/wwwroot/Build/build_web.wasm
Binary file not shown.