Skip to content

Commit

Permalink
Store user's yay/boo/meh faces (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden authored Aug 12, 2024
2 parents 4e7e55f + ec7a03f commit ad65f52
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Refresh.GameServer/Database/GameDatabaseContext.Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ public void UpdateUserData(GameUser user, SerializedUpdateData data, TokenGame g
user.BetaIconHash = data.IconHash;
break;
}
if (data.YayFaceHash != null)
user.YayFaceHash = data.YayFaceHash;
if (data.BooFaceHash != null)
user.BooFaceHash = data.BooFaceHash;
if (data.MehFaceHash != null)
user.MehFaceHash = data.MehFaceHash;
});
}

Expand Down
2 changes: 1 addition & 1 deletion Refresh.GameServer/Database/GameDatabaseProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected GameDatabaseProvider(IDateTimeProvider time)
this._time = time;
}

protected override ulong SchemaVersion => 140;
protected override ulong SchemaVersion => 141;

protected override string Filename => "refreshGameServer.realm";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public class ApiGameUserResponse : IApiResponse, IDataConvertableFrom<ApiGameUse
public required string UserId { get; set; }
public required string Username { get; set; }
public required string IconHash { get; set; }

public required string YayFaceHash { get; set; }
public required string BooFaceHash { get; set; }
public required string MehFaceHash { get; set; }
public required string Description { get; set; }
public required ApiGameLocationResponse Location { get; set; }
public required DateTimeOffset JoinDate { get; set; }
Expand All @@ -35,7 +39,12 @@ public class ApiGameUserResponse : IApiResponse, IDataConvertableFrom<ApiGameUse
{
UserId = user.UserId.ToString()!,
Username = user.Username,
IconHash = dataContext.Database.GetAssetFromHash(user.IconHash)?.GetAsIcon(TokenGame.Website, dataContext) ?? user.IconHash,

IconHash = dataContext.GetIconFromHash(user.IconHash),
YayFaceHash = dataContext.GetIconFromHash(user.YayFaceHash),
BooFaceHash = dataContext.GetIconFromHash(user.BooFaceHash),
MehFaceHash = dataContext.GetIconFromHash(user.MehFaceHash),

Description = user.Description,
Location = ApiGameLocationResponse.FromLocation(user.LocationX, user.LocationY)!,
JoinDate = user.JoinDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class GameUserResponse : IDataConvertableFrom<GameUserResponse, GameUser>
[XmlElement("location")] public required GameLocation Location { get; set; }
[XmlElement("planets")] public required string PlanetsHash { get; set; }

[XmlElement("yay2")] public required string YayFaceHash { get; set; }
[XmlElement("boo2")] public required string BooFaceHash { get; set; }
[XmlElement("meh2")] public required string MehFaceHash { get; set; }

[XmlElement("npHandle")] public required SerializedUserHandle Handle { get; set; }
[XmlElement("commentCount")] public int CommentCount { get; set; }
[XmlElement("commentsEnabled")] public bool CommentsEnabled { get; set; }
Expand Down Expand Up @@ -61,6 +65,10 @@ public class GameUserResponse : IDataConvertableFrom<GameUserResponse, GameUser>
Location = new GameLocation(old.LocationX, old.LocationY),
PlanetsHash = "0",

YayFaceHash = dataContext.GetIconFromHash(old.YayFaceHash),
BooFaceHash = dataContext.GetIconFromHash(old.BooFaceHash),
MehFaceHash = dataContext.GetIconFromHash(old.MehFaceHash),

Handle = SerializedUserHandle.FromUser(old, dataContext),
CommentCount = dataContext.Database.GetTotalCommentsForProfile(old),
CommentsEnabled = true,
Expand Down
5 changes: 5 additions & 0 deletions Refresh.GameServer/Types/Data/DataContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ public class DataContext
public GameUser? User => this.Token?.User;
public TokenGame Game => this.Token?.TokenGame ?? TokenGame.Website;
public TokenPlatform Platform => this.Token?.TokenPlatform ?? TokenPlatform.Website;

public string GetIconFromHash(string hash)
{
return this.Database.GetAssetFromHash(hash)?.GetAsIcon(this.Game, this) ?? hash;
}
}
4 changes: 4 additions & 0 deletions Refresh.GameServer/Types/UserData/GameUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public partial class GameUser : IRealmObject, IRateLimitUser
public string Lbp3PlanetsHash { get; set; } = "0";
public string VitaPlanetsHash { get; set; } = "0";

public string YayFaceHash { get; set; } = "0";
public string BooFaceHash { get; set; } = "0";
public string MehFaceHash { get; set; } = "0";

public bool AllowIpAuthentication { get; set; }
public string? CurrentVerifiedIp { get; set; }

Expand Down
9 changes: 9 additions & 0 deletions Refresh.GameServer/Types/UserData/SerializedUpdateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ public class SerializedUpdateData

[XmlElement("icon")]
public string? IconHash { get; set; }

[XmlElement("yay2")]
public string? YayFaceHash { get; set; }

[XmlElement("boo2")]
public string? BooFaceHash { get; set; }

[XmlElement("meh2")]
public string? MehFaceHash { get; set; }
}

0 comments on commit ad65f52

Please sign in to comment.