public static string ViewMerit(Merit merit, ArcadeUser user = null) { var info = new StringBuilder(); bool allowTooltips = user?.Config?.Tooltips ?? true; bool hasUnlocked = user != null && HasUnlocked(user, merit); if (merit.Criteria == null) { info.AppendLine(Format.Warning("This is an exclusive merit.")); } if (allowTooltips) { var tooltips = new List <string>(); if (user != null && CanClaim(user, merit)) { tooltips.Add($"Type `claim {merit.Id}` to claim this merit."); } if (merit.Hidden) { tooltips.Add("This merit is excluded from completion progress."); } info.AppendLine(Format.Tooltip(tooltips)); } if (merit.Criteria == null || (allowTooltips && (merit.Hidden || user != null && CanClaim(user, merit)))) { info.AppendLine(); } info.AppendLine(GetPreview(merit)); string quote = GetQuote(merit, hasUnlocked); if (Check.NotNull(quote)) { info.AppendLine(quote); } if (hasUnlocked) { info.AppendLine($"> Unlocked: {Format.FullTime(user.Merits[merit.Id].AchievedAt, '.')}"); } info.AppendLine($"> Rank: **{merit.Rank.ToString()}**"); if (merit.Reward != null) { info.Append(ViewReward(merit.Reward, hasUnlocked && user.Merits[merit.Id]?.IsClaimed == true)); } return(info.ToString()); }
public static long GetScore(ArcadeUser user) { long score = 0; foreach (string id in user.Merits.Keys) { Merit merit = GetMerit(id); score += merit.Score; } return(score); }
private static string WriteLastUnlocked(ArcadeUser user) { Merit merit = GetNewestUnlocked(user); if (merit == null) { return($"The directory of all known milestones."); } string icon = Check.NotNull(merit.Icon) ? $"{merit.Icon}" : "•"; return($"Last Unlocked: {icon} **{merit.Name}** (**{merit.Score:##,0}**m)"); }
private static string GetQuote(Merit merit, bool isUnlocked = false) { string quote = !Check.NotNull(merit.LockQuote) || isUnlocked ? merit.Quote : merit.LockQuote; if (Check.NotNull(quote)) { string display = $"\"{quote}\""; if (merit.Hidden) { display = Format.Spoiler(display); } return($"> {display}"); } return(""); }
private static string GetPreview(Merit merit) { string icon = (Check.NotNull(merit.Icon) ? $"{merit.Icon}" : "•"); return($"> {icon} **{merit.Name}** (**{merit.Score:##,0}**m)"); }
public static bool HasUnlocked(ArcadeUser user, Merit merit) => user.Merits.ContainsKey(merit.Id);
public static string GetQueryPreview(Merit merit, ArcadeUser user = null) { string icon = (Check.NotNull(merit.Icon) ? $"{merit.Icon}" : "•"); return($"> `{merit.Id}`\n> {icon} **{merit.Name}**{(user != null && HasUnlocked(user, merit) ? "\\*" : "")} (**{merit.Score:##,0}**m)"); }