mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-14 05:42:27 +00:00
LittleBigPlanet 3 Adventure Support (#477)
* Baseline LBP3 Adventure slot support VERY unsafe and hacky to use as of now, this is just testing the waters. * ADC file type checking * Refactor & trimming This might need to be adjusted if any feature is found to be missing * isAdventure added to API * Prototype Adventure icons for Website I am not an artist, please make this more in line with the originals. * Override border radius for LBP3 Adventures * Cleaning * Remove WriteLine and unused property * Remove unused libraries * Handle tracking and submitting of Adventure scores * Check for null instead of 0 Non-adventure slots will report null, not 0 * Score for adventure slot instead of main slot * Tweaks for PR * Identify levels for photos by level resource Verify this doesn't break anything. * SlotCardPartial merge with main changes * PR resolution 2 * probably not what was wanted Use variables for style extension * Internal slots already properly identified * Return line breaks to end of Slot.cs * Remove line break added by Github thanks * Github. * Make this a one-liner * Reduce to two lines * This can also be one line * This can *also* be one line * Update ProjectLighthouse.Servers.Website/Pages/Partials/SlotCardPartial.cshtml Co-authored-by: Josh <josh@slendy.pw> * PR changes * Update ProjectLighthouse/Migrations/20220916141401_ScoreboardAdvSlot.cs Co-authored-by: Josh <josh@slendy.pw> Co-authored-by: Josh <josh@slendy.pw>
This commit is contained in:
parent
83a905c8a2
commit
dfd1d9b748
14 changed files with 107 additions and 22 deletions
|
@ -26,7 +26,8 @@ public class ScoreController : ControllerBase
|
|||
}
|
||||
|
||||
[HttpPost("scoreboard/{slotType}/{id:int}")]
|
||||
public async Task<IActionResult> SubmitScore(string slotType, int id, [FromQuery] bool lbp1 = false, [FromQuery] bool lbp2 = false, [FromQuery] bool lbp3 = false)
|
||||
[HttpPost("scoreboard/{slotType}/{id:int}/{childId:int}")]
|
||||
public async Task<IActionResult> SubmitScore(string slotType, int id, int? childId, [FromQuery] bool lbp1 = false, [FromQuery] bool lbp2 = false, [FromQuery] bool lbp3 = false)
|
||||
{
|
||||
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
|
||||
if (token == null) return this.StatusCode(403, "");
|
||||
|
@ -78,6 +79,7 @@ public class ScoreController : ControllerBase
|
|||
if (slotType == "developer") id = await SlotHelper.GetPlaceholderSlotId(this.database, id, SlotType.Developer);
|
||||
|
||||
score.SlotId = id;
|
||||
score.ChildSlotId = childId;
|
||||
|
||||
Slot? slot = this.database.Slots.FirstOrDefault(s => s.SlotId == score.SlotId);
|
||||
if (slot == null)
|
||||
|
@ -116,12 +118,13 @@ public class ScoreController : ControllerBase
|
|||
Type = score.Type,
|
||||
Points = score.Points,
|
||||
SlotId = score.SlotId,
|
||||
ChildSlotId = score.ChildSlotId
|
||||
};
|
||||
|
||||
IQueryable<Score> existingScore = this.database.Scores.Where(s => s.SlotId == playerScore.SlotId)
|
||||
.Where(s => s.PlayerIdCollection == playerScore.PlayerIdCollection)
|
||||
.Where(s => s.Type == playerScore.Type);
|
||||
|
||||
.Where(s => childId != 0 || s.ChildSlotId == childId)
|
||||
.Where(s => s.PlayerIdCollection == playerScore.PlayerIdCollection)
|
||||
.Where(s => s.Type == playerScore.Type);
|
||||
if (existingScore.Any())
|
||||
{
|
||||
Score first = existingScore.First(s => s.SlotId == playerScore.SlotId);
|
||||
|
@ -137,13 +140,14 @@ public class ScoreController : ControllerBase
|
|||
|
||||
await this.database.SaveChangesAsync();
|
||||
|
||||
string myRanking = this.getScores(score.SlotId, score.Type, username, -1, 5, "scoreboardSegment");
|
||||
string myRanking = this.getScores(score.SlotId, score.Type, username, -1, 5, "scoreboardSegment", childId: score.ChildSlotId);
|
||||
|
||||
return this.Ok(myRanking);
|
||||
}
|
||||
|
||||
[HttpGet("friendscores/{slotType}/{slotId:int}/{type:int}")]
|
||||
public async Task<IActionResult> FriendScores(string slotType, int slotId, int type, [FromQuery] int pageStart = -1, [FromQuery] int pageSize = 5)
|
||||
[HttpGet("friendscores/{slotType}/{slotId:int}/{childId:int}/{type:int}")]
|
||||
public async Task<IActionResult> FriendScores(string slotType, int slotId, int? childId, int type, [FromQuery] int pageStart = -1, [FromQuery] int pageSize = 5)
|
||||
{
|
||||
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
|
||||
if (token == null) return this.StatusCode(403, "");
|
||||
|
@ -169,12 +173,13 @@ public class ScoreController : ControllerBase
|
|||
if (friendUsername != null) friendNames.Add(friendUsername);
|
||||
}
|
||||
|
||||
return this.Ok(this.getScores(slotId, type, username, pageStart, pageSize, "scores", friendNames.ToArray()));
|
||||
return this.Ok(this.getScores(slotId, type, username, pageStart, pageSize, "scores", friendNames.ToArray(), childId));
|
||||
}
|
||||
|
||||
[HttpGet("topscores/{slotType}/{slotId:int}/{type:int}")]
|
||||
[HttpGet("topscores/{slotType}/{slotId:int}/{childId:int}/{type:int}")]
|
||||
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
|
||||
public async Task<IActionResult> TopScores(string slotType, int slotId, int type, [FromQuery] int pageStart = -1, [FromQuery] int pageSize = 5)
|
||||
public async Task<IActionResult> TopScores(string slotType, int slotId, int? childId, int type, [FromQuery] int pageStart = -1, [FromQuery] int pageSize = 5)
|
||||
{
|
||||
GameToken? token = await this.database.GameTokenFromRequest(this.Request);
|
||||
if (token == null) return this.StatusCode(403, "");
|
||||
|
@ -187,7 +192,7 @@ public class ScoreController : ControllerBase
|
|||
|
||||
if (slotType == "developer") slotId = await SlotHelper.GetPlaceholderSlotId(this.database, slotId, SlotType.Developer);
|
||||
|
||||
return this.Ok(this.getScores(slotId, type, username, pageStart, pageSize));
|
||||
return this.Ok(this.getScores(slotId, type, username, pageStart, pageSize, childId: childId));
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "PossibleMultipleEnumeration")]
|
||||
|
@ -199,7 +204,8 @@ public class ScoreController : ControllerBase
|
|||
int pageStart = -1,
|
||||
int pageSize = 5,
|
||||
string rootName = "scores",
|
||||
string[]? playerIds = null
|
||||
string[]? playerIds = null,
|
||||
int? childId = 0
|
||||
)
|
||||
{
|
||||
|
||||
|
@ -207,8 +213,9 @@ public class ScoreController : ControllerBase
|
|||
// var needed for Anonymous type returned from SELECT
|
||||
var rankedScores = this.database.Scores
|
||||
.Where(s => s.SlotId == slotId && s.Type == type)
|
||||
.AsEnumerable()
|
||||
.Where(s => s.ChildSlotId == null || s.ChildSlotId == childId)
|
||||
.Where(s => playerIds == null || playerIds.Any(id => s.PlayerIdCollection.Contains(id)))
|
||||
.AsEnumerable()
|
||||
.OrderByDescending(s => s.Points)
|
||||
.ThenBy(s => s.ScoreId)
|
||||
.ToList()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue