Added three new categories to LBP3 (#567)

* Added three new categories to LBP3

* removed my comment in most hearted
This commit is contained in:
W0lf4llo 2022-12-01 23:34:25 -05:00 committed by GitHub
commit 67cfc29699
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 0 deletions

View file

@ -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());

View file

@ -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<Slot> 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);
}

View file

@ -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<Slot> 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);
}

View file

@ -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<Slot> 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);
}