mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-07 12:28:39 +00:00
Add user, ClientsConnected, and Location type
This commit is contained in:
parent
9bd26f6fb2
commit
ceac914475
4 changed files with 103 additions and 0 deletions
|
@ -11,6 +11,12 @@ namespace ProjectLighthouse.Serialization {
|
|||
|
||||
public static string GetStringElement(string key, object value) => $"<{key}>{value}</{key}>";
|
||||
|
||||
public static string GetTaggedStringElement(KeyValuePair<string, object> pair, KeyValuePair<string, object> tagPair) =>
|
||||
$"<{pair.Key} {tagPair.Key}=\"{tagPair.Value}\">{pair.Value}</{pair.Key}>";
|
||||
|
||||
public static string GetTaggedStringElement(string key, object value, string tagKey, object tagValue) =>
|
||||
$"<{key} {tagKey}=\"{tagValue}\">{value}</{key}>";
|
||||
|
||||
public static string GetElements(params KeyValuePair<string, object>[] pairs) =>
|
||||
pairs.Aggregate(string.Empty, (current, pair) => current + GetStringElement(pair));
|
||||
}
|
||||
|
|
20
ProjectLighthouse/Types/ClientsConnected.cs
Normal file
20
ProjectLighthouse/Types/ClientsConnected.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using ProjectLighthouse.Serialization;
|
||||
|
||||
namespace ProjectLighthouse.Types {
|
||||
public class ClientsConnected {
|
||||
public bool Lbp1 { get; set; }
|
||||
public bool Lbp2 { get; set; }
|
||||
public bool LbpMe { get; set; }
|
||||
public bool Lbp3Ps3 { get; set; }
|
||||
public bool Lbp3Ps4 { get; set; }
|
||||
|
||||
public string Serialize() {
|
||||
return LbpSerializer.GetStringElement("clientsConnected",
|
||||
LbpSerializer.GetStringElement("lbp1", Lbp1) +
|
||||
LbpSerializer.GetStringElement("lbp2", Lbp2) +
|
||||
LbpSerializer.GetStringElement("lbpme", LbpMe) +
|
||||
LbpSerializer.GetStringElement("lbp3ps3", Lbp3Ps3) +
|
||||
LbpSerializer.GetStringElement("lbp3ps4", Lbp3Ps4));
|
||||
}
|
||||
}
|
||||
}
|
13
ProjectLighthouse/Types/Location.cs
Normal file
13
ProjectLighthouse/Types/Location.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using ProjectLighthouse.Serialization;
|
||||
|
||||
namespace ProjectLighthouse {
|
||||
public class Location {
|
||||
public int X;
|
||||
public int Y;
|
||||
|
||||
public string Serialize() {
|
||||
return LbpSerializer.GetStringElement("x", this.X) +
|
||||
LbpSerializer.GetStringElement("Y", this.Y);
|
||||
}
|
||||
}
|
||||
}
|
64
ProjectLighthouse/Types/User.cs
Normal file
64
ProjectLighthouse/Types/User.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
using ProjectLighthouse.Serialization;
|
||||
using ProjectLighthouse.Types;
|
||||
|
||||
namespace ProjectLighthouse {
|
||||
public class User {
|
||||
public string Username { get; set; }
|
||||
public string IconHash { get; set; }
|
||||
public int Game { get; set; }
|
||||
public int Lists { get; set; }
|
||||
public static int ListsQuota = 20;
|
||||
public int HeartCount { get; set; }
|
||||
public string YayHash { get; set; }
|
||||
public string BooHash { get; set; }
|
||||
public string Biography { get; set; }
|
||||
public int ReviewCount { get; set; }
|
||||
public int CommentCount { get; set; }
|
||||
public int PhotosByMeCount { get; set; }
|
||||
public int PhotosWithMeCount { get; set; }
|
||||
public bool CommentsEnabled { get; set; }
|
||||
public Location Location { get; set; }
|
||||
public string Pins { get; set; }
|
||||
public int StaffChallengeGoldCount { get; set; }
|
||||
public int StaffChallengeSilverCount { get; set; }
|
||||
public int StaffChallengeBronzeCount { get; set; }
|
||||
public ClientsConnected ClientsConnected;
|
||||
|
||||
#region Slots
|
||||
|
||||
public static int EntitledSlots = 20;
|
||||
public int UsedSlots { get; set; }
|
||||
public int FreeSlots => EntitledSlots - UsedSlots;
|
||||
|
||||
private static string[] slotTypes = {
|
||||
"lbp1",
|
||||
"lbp2",
|
||||
"lbp3",
|
||||
"crossControl"
|
||||
};
|
||||
|
||||
private string SerializeSlots() {
|
||||
string slots = string.Empty;
|
||||
|
||||
foreach(string slotType in slotTypes) {
|
||||
slots += LbpSerializer.GetStringElement(slotType + "UsedSlots", UsedSlots);
|
||||
slots += LbpSerializer.GetStringElement(slotType + "EntitledSlots", EntitledSlots);
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
slots += LbpSerializer.GetStringElement(slotType + slotType == "crossControl" ? "PurchsedSlots" : "PurchasedSlots", 0);
|
||||
slots += LbpSerializer.GetStringElement(slotType + "FreeSlots", FreeSlots);
|
||||
}
|
||||
return slots;
|
||||
|
||||
}
|
||||
|
||||
#endregion Slots
|
||||
|
||||
public string Serialize() {
|
||||
string user = LbpSerializer.GetTaggedStringElement("npHandle", Username, "icon", IconHash) +
|
||||
this.SerializeSlots() +
|
||||
LbpSerializer.GetStringElement("game", Game);
|
||||
|
||||
return LbpSerializer.GetTaggedStringElement("user", user, "type", "user");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue