Skip to content

Commit

Permalink
Prepare for adding badges
Browse files Browse the repository at this point in the history
  • Loading branch information
byBlurr committed Feb 13, 2021
1 parent 09f6878 commit a6ad47f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions LorisAngel.Bot/Database/ProfileDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private static async Task<List<LoriUser>> GetAllUsersAsync()
if (motto == null) motto = "";
if (claimedAt == null) claimedAt = new DateTime();

LoriUser newUser = new LoriUser(id, name, createdOn, joinedOn, lastSeen, status, "", lastUpdated, motto, activity, currency, claimedAt);
LoriUser newUser = new LoriUser(id, name, createdOn, joinedOn, lastSeen, status, new List<int>(), lastUpdated, motto, activity, currency, claimedAt);
users.Add(newUser);
}
}
Expand Down Expand Up @@ -350,7 +350,7 @@ public static void CreateNewUser(IUser user)
{
DateTime lastseen = new DateTime();
if (user.Status != UserStatus.Offline && user.Status != UserStatus.Invisible) lastseen = DateTime.Now;
LoriUser newUser = new LoriUser(user.Id, "", user.CreatedAt.DateTime, DateTime.Now, lastseen, user.Status.ToString(), "", DateTime.Now);
LoriUser newUser = new LoriUser(user.Id, "", user.CreatedAt.DateTime, DateTime.Now, lastseen, user.Status.ToString(), new List<int>(), DateTime.Now);
newUser.SetNew();
Users.Add(newUser);
}
Expand Down
13 changes: 11 additions & 2 deletions LorisAngel.Common/Objects/LoriUser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace LorisAngel.Common.Objects
Expand All @@ -13,7 +14,7 @@ public class LoriUser
public string Status { get; private set; }
public string Activity { get; private set; }
public string Motto { get; private set; }
public string Badges { get; private set; } // WILL BE A LIST OF BADGES ONCE BADGES ADDED
public List<int> Badges { get; private set; }
public int Currency;
public string Avatar { get; private set; } // WILL BE THE AVATAR ON THEIR PROFILE
public string ProfileCard { get; private set; } // WILL BE THE PROFILE BACKGROUND
Expand All @@ -22,7 +23,7 @@ public class LoriUser
public bool IsNew { get; set; }
public DateTime Claimed { get; set; }

public LoriUser(ulong id, string name, DateTime createdOn, DateTime joinedOn, DateTime lastSeen, string status, string badges, DateTime lastUpdated, string activity = "", string motto = "", int currency = 0, DateTime claimedAt = new DateTime())
public LoriUser(ulong id, string name, DateTime createdOn, DateTime joinedOn, DateTime lastSeen, string status, List<int> badges, DateTime lastUpdated, string activity = "", string motto = "", int currency = 0, DateTime claimedAt = new DateTime())
{
Id = id;
Name = name.Normalize() ?? throw new ArgumentNullException(nameof(name));
Expand Down Expand Up @@ -123,6 +124,14 @@ public void UpdateName(string newName)
}
}

public void AddBadge(int badgeId)
{
if (!Badges.Contains(badgeId)) Badges.Add(badgeId);

HasChanged = true;
LastUpdated = DateTime.Now;
}

private string Fix(string text)
{
string fixedText = text.Normalize();
Expand Down

0 comments on commit a6ad47f

Please sign in to comment.