diff --git a/ProjectLighthouse/Levels/Categories/CategoryHelper.cs b/ProjectLighthouse/Levels/Categories/CategoryHelper.cs index db7a38b9..7330fbe9 100644 --- a/ProjectLighthouse/Levels/Categories/CategoryHelper.cs +++ b/ProjectLighthouse/Levels/Categories/CategoryHelper.cs @@ -9,7 +9,10 @@ public static class CategoryHelper static CategoryHelper() { Categories.Add(new TeamPicksCategory()); + Categories.Add(new MostHeartedCategory()); Categories.Add(new NewestLevelsCategory()); + Categories.Add(new MostPlayedCategory()); + Categories.Add(new HighestRatedCategory()); Categories.Add(new QueueCategory()); Categories.Add(new HeartedCategory()); Categories.Add(new LuckyDipCategory()); diff --git a/ProjectLighthouse/Levels/Categories/HighestRatedCategory.cs b/ProjectLighthouse/Levels/Categories/HighestRatedCategory.cs new file mode 100644 index 00000000..09a9b249 --- /dev/null +++ b/ProjectLighthouse/Levels/Categories/HighestRatedCategory.cs @@ -0,0 +1,28 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Linq; +using LBPUnion.ProjectLighthouse.Extensions; +using LBPUnion.ProjectLighthouse.PlayerData; +using YamlDotNet.Core.Tokens; + +namespace LBPUnion.ProjectLighthouse.Levels.Categories; + +public class HighestRatedCategory : Category +{ + Random rand = new(); + public override string Name { get; set; } = "Highest Rated"; + public override string Description { get; set; } = "Community Highest Rated content"; + public override string IconHash { get; set; } = "g820603"; + public override string Endpoint { get; set; } = "thumbs"; + public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().OrderByDescending(s => s.Thumbsup).FirstOrDefault(); + public override IEnumerable GetSlots + (Database database, int pageStart, int pageSize) + => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) + .AsEnumerable() + .OrderByDescending(s => s.Thumbsup) + .ThenBy(_ => rand.Next()) + .Skip(Math.Max(0, pageStart - 1)) + .Take(Math.Min(pageSize, 20)); + public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); +} \ No newline at end of file diff --git a/ProjectLighthouse/Levels/Categories/MostHeartedCategory.cs b/ProjectLighthouse/Levels/Categories/MostHeartedCategory.cs new file mode 100644 index 00000000..04c54b01 --- /dev/null +++ b/ProjectLighthouse/Levels/Categories/MostHeartedCategory.cs @@ -0,0 +1,27 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Linq; +using LBPUnion.ProjectLighthouse.Extensions; +using LBPUnion.ProjectLighthouse.PlayerData; + +namespace LBPUnion.ProjectLighthouse.Levels.Categories; + +public class MostHeartedCategory : Category +{ + Random rand = new(); + public override string Name { get; set; } = "Most Hearted"; + public override string Description { get; set; } = "The Most Hearted Content"; + public override string IconHash { get; set; } = "g820607"; + public override string Endpoint { get; set; } = "mostHearted"; + public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().OrderByDescending(s => s.Hearts).FirstOrDefault(); + public override IEnumerable GetSlots + (Database database, int pageStart, int pageSize) + => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) + .AsEnumerable() + .OrderByDescending(s => s.Hearts) + .ThenBy(_ => rand.Next()) + .Skip(Math.Max(0, pageStart - 1)) + .Take(Math.Min(pageSize, 20)); + public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); +} \ No newline at end of file diff --git a/ProjectLighthouse/Levels/Categories/MostPlayedCategory.cs b/ProjectLighthouse/Levels/Categories/MostPlayedCategory.cs new file mode 100644 index 00000000..1828bb78 --- /dev/null +++ b/ProjectLighthouse/Levels/Categories/MostPlayedCategory.cs @@ -0,0 +1,28 @@ +#nullable enable +using System; +using System.Collections.Generic; +using System.Linq; +using LBPUnion.ProjectLighthouse.Extensions; +using LBPUnion.ProjectLighthouse.PlayerData; +using YamlDotNet.Core.Tokens; + +namespace LBPUnion.ProjectLighthouse.Levels.Categories; + +public class MostPlayedCategory : Category +{ + Random rand = new(); + public override string Name { get; set; } = "Most Played"; + public override string Description { get; set; } = "The most played content"; + public override string IconHash { get; set; } = "g820608"; + public override string Endpoint { get; set; } = "mostUniquePlays"; + public override Slot? GetPreviewSlot(Database database) => database.Slots.Where(s => s.Type == SlotType.User).AsEnumerable().OrderByDescending(s => s.PlaysUnique).FirstOrDefault(); + public override IEnumerable GetSlots + (Database database, int pageStart, int pageSize) + => database.Slots.ByGameVersion(GameVersion.LittleBigPlanet3, false, true) + .AsEnumerable() + .OrderByDescending(s => s.PlaysUnique) + .ThenBy(_ => rand.Next()) + .Skip(Math.Max(0, pageStart - 1)) + .Take(Math.Min(pageSize, 20)); + public override int GetTotalSlots(Database database) => database.Slots.Count(s => s.Type == SlotType.User); +} \ No newline at end of file