mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 11:58:38 +00:00
Return proper GameVersion when calling GetGameFilter on vita/psp
This commit is contained in:
parent
00007f9683
commit
5450822291
1 changed files with 20 additions and 8 deletions
|
@ -230,9 +230,12 @@ public class SlotsController : ControllerBase
|
||||||
[FromQuery] string? dateFilterType = null
|
[FromQuery] string? dateFilterType = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
|
||||||
|
if (token == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
Random rand = new();
|
Random rand = new();
|
||||||
|
|
||||||
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType)
|
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType, token.GameVersion)
|
||||||
.AsEnumerable()
|
.AsEnumerable()
|
||||||
.OrderByDescending(s => s.Thumbsup)
|
.OrderByDescending(s => s.Thumbsup)
|
||||||
.ThenBy(_ => rand.Next())
|
.ThenBy(_ => rand.Next())
|
||||||
|
@ -255,16 +258,19 @@ public class SlotsController : ControllerBase
|
||||||
[FromQuery] string? dateFilterType = null
|
[FromQuery] string? dateFilterType = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
|
||||||
|
if (token == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
Random rand = new();
|
Random rand = new();
|
||||||
|
|
||||||
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType)
|
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType, token.GameVersion)
|
||||||
.AsEnumerable()
|
.AsEnumerable()
|
||||||
.OrderByDescending
|
.OrderByDescending
|
||||||
(
|
(
|
||||||
|
// probably not the best way to do this?
|
||||||
s =>
|
s =>
|
||||||
{
|
{
|
||||||
// probably not the best way to do this?
|
return this.GetGameFilter(gameFilterType, token.GameVersion) switch
|
||||||
return this.GetGameFilter(gameFilterType) switch
|
|
||||||
{
|
{
|
||||||
GameVersion.LittleBigPlanet1 => s.PlaysLBP1Unique,
|
GameVersion.LittleBigPlanet1 => s.PlaysLBP1Unique,
|
||||||
GameVersion.LittleBigPlanet2 => s.PlaysLBP2Unique,
|
GameVersion.LittleBigPlanet2 => s.PlaysLBP2Unique,
|
||||||
|
@ -294,9 +300,12 @@ public class SlotsController : ControllerBase
|
||||||
[FromQuery] string? dateFilterType = null
|
[FromQuery] string? dateFilterType = null
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
|
||||||
|
if (token == null) return this.StatusCode(403, "");
|
||||||
|
|
||||||
Random rand = new();
|
Random rand = new();
|
||||||
|
|
||||||
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType)
|
IEnumerable<Slot> slots = this.FilterByRequest(gameFilterType, dateFilterType, token.GameVersion)
|
||||||
.AsEnumerable()
|
.AsEnumerable()
|
||||||
.OrderByDescending(s => s.Hearts)
|
.OrderByDescending(s => s.Hearts)
|
||||||
.ThenBy(_ => rand.Next())
|
.ThenBy(_ => rand.Next())
|
||||||
|
@ -308,8 +317,11 @@ public class SlotsController : ControllerBase
|
||||||
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "hint_start", pageStart + Math.Min(pageSize, 30)));
|
return this.Ok(LbpSerializer.TaggedStringElement("slots", response, "hint_start", pageStart + Math.Min(pageSize, 30)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameVersion GetGameFilter(string? gameFilterType)
|
public GameVersion GetGameFilter(string? gameFilterType, GameVersion version)
|
||||||
{
|
{
|
||||||
|
if (version == GameVersion.LittleBigPlanetVita) return GameVersion.LittleBigPlanetVita;
|
||||||
|
if (version == GameVersion.LittleBigPlanetPSP) return GameVersion.LittleBigPlanetPSP;
|
||||||
|
|
||||||
return gameFilterType switch
|
return gameFilterType switch
|
||||||
{
|
{
|
||||||
"lbp1" => GameVersion.LittleBigPlanet1,
|
"lbp1" => GameVersion.LittleBigPlanet1,
|
||||||
|
@ -321,7 +333,7 @@ public class SlotsController : ControllerBase
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQueryable<Slot> FilterByRequest(string? gameFilterType, string? dateFilterType)
|
public IQueryable<Slot> FilterByRequest(string? gameFilterType, string? dateFilterType, GameVersion version)
|
||||||
{
|
{
|
||||||
string _dateFilterType = dateFilterType ?? "";
|
string _dateFilterType = dateFilterType ?? "";
|
||||||
|
|
||||||
|
@ -332,7 +344,7 @@ public class SlotsController : ControllerBase
|
||||||
_ => 0,
|
_ => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
GameVersion gameVersion = this.GetGameFilter(gameFilterType);
|
GameVersion gameVersion = this.GetGameFilter(gameFilterType, version);
|
||||||
|
|
||||||
IQueryable<Slot> whereSlots;
|
IQueryable<Slot> whereSlots;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue