@Model.ProfileUser!.Username's user page
-
+
+ @Model.ProfileUser.Status
+
@Model.ProfileUser.Hearts
@Model.ProfileUser.Comments
diff --git a/ProjectLighthouse/Types/GameVersion.cs b/ProjectLighthouse/Types/GameVersion.cs
index c0530d9c..2ad35019 100644
--- a/ProjectLighthouse/Types/GameVersion.cs
+++ b/ProjectLighthouse/Types/GameVersion.cs
@@ -9,4 +9,9 @@ namespace LBPUnion.ProjectLighthouse.Types
LittleBigPlanetPSP = 4,
Unknown = -1,
}
+
+ public static class GameVersionExtensions
+ {
+ public static string ToPrettyString(this GameVersion gameVersion) => gameVersion.ToString().Replace("LittleBigPlanet", "LittleBigPlanet ");
+ }
}
\ No newline at end of file
diff --git a/ProjectLighthouse/Types/Profiles/LastMatch.cs b/ProjectLighthouse/Types/Profiles/LastMatch.cs
index ec637c14..832430cd 100644
--- a/ProjectLighthouse/Types/Profiles/LastMatch.cs
+++ b/ProjectLighthouse/Types/Profiles/LastMatch.cs
@@ -8,5 +8,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Profiles
public int UserId { get; set; }
public long Timestamp { get; set; }
+
+ public GameVersion GameVersion { get; set; } = GameVersion.Unknown;
}
}
\ No newline at end of file
diff --git a/ProjectLighthouse/Types/User.cs b/ProjectLighthouse/Types/User.cs
index f783bb7b..f87a872c 100644
--- a/ProjectLighthouse/Types/User.cs
+++ b/ProjectLighthouse/Types/User.cs
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types.Profiles;
using LBPUnion.ProjectLighthouse.Types.Settings;
@@ -97,6 +98,22 @@ namespace LBPUnion.ProjectLighthouse.Types
public bool IsAdmin { get; set; } = false;
+ #nullable enable
+ [NotMapped]
+ public string Status {
+ get {
+ using Database database = new();
+ LastMatch? lastMatch = database.LastMatches.Where
+ (l => l.UserId == this.UserId)
+ .FirstOrDefault(l => TimestampHelper.Timestamp - l.Timestamp < 300);
+
+ if (lastMatch == null) return "Offline";
+
+ return "Currently online on " + lastMatch.GameVersion.ToPrettyString();
+ }
+ }
+ #nullable disable
+
public string Serialize(GameVersion gameVersion = GameVersion.LittleBigPlanet1)
{
string user = LbpSerializer.TaggedStringElement("npHandle", this.Username, "icon", this.IconHash) +