-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new-postgres
- Loading branch information
Showing
70 changed files
with
1,277 additions
and
719 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Refresh.GameServer/Database/Activity/GameDatabaseContext.ActivityRead.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Diagnostics; | ||
using Refresh.GameServer.Types.Activity; | ||
using Refresh.GameServer.Types.Levels; | ||
using Refresh.GameServer.Types.Relations; | ||
using Refresh.GameServer.Types.UserData; | ||
using Refresh.GameServer.Types.UserData.Leaderboard; | ||
|
||
namespace Refresh.GameServer.Database; | ||
|
||
public partial class GameDatabaseContext // ActivityRead | ||
{ | ||
public GameUser? GetUserFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.User) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.User)})"); | ||
|
||
Debug.Assert(e.StoredObjectId != null); | ||
|
||
return this.GetUserByObjectId(e.StoredObjectId); | ||
} | ||
|
||
public GameLevel? GetLevelFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.Level) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.Level)})"); | ||
|
||
Debug.Assert(e.StoredSequentialId != null); | ||
|
||
return this.GetLevelById(e.StoredSequentialId.Value); | ||
} | ||
|
||
public GameSubmittedScore? GetScoreFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.Score) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.Score)})"); | ||
|
||
Debug.Assert(e.StoredObjectId != null); | ||
|
||
return this.GetScoreByObjectId(e.StoredObjectId); | ||
} | ||
|
||
public RateLevelRelation? GetRateLevelRelationFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.RateLevelRelation) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.RateLevelRelation)})"); | ||
|
||
Debug.Assert(e.StoredObjectId != null); | ||
|
||
return this.RateLevelRelations | ||
.FirstOrDefault(l => l.RateLevelRelationId == e.StoredObjectId); | ||
} | ||
} |
Oops, something went wrong.