-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:PuzzleServer/mainpuzzleserver
- Loading branch information
Showing
16 changed files
with
913 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@page "/{eventId}/Events/FastestSolves" | ||
@model ServerCore.Pages.Events.FastestSolvesModel | ||
|
||
@{ | ||
ViewData["Title"] = "Fastest Solves"; | ||
} | ||
|
||
<h2>Fastest Solves</h2> | ||
|
||
<table class="table table-condensed"> | ||
<thead> | ||
<tr> | ||
<th> | ||
Rank | ||
</th> | ||
<th> | ||
@Html.DisplayNameFor(model => model.Puzzles[0].Puzzle.Name) | ||
</th> | ||
<th> | ||
Teams | ||
</th> | ||
<th> | ||
First | ||
</th> | ||
<th> | ||
Second | ||
</th> | ||
<th> | ||
Third | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@for (int y = 0; y < Model.Puzzles.Count; y++) { | ||
var puzzle = Model.Puzzles[y]; | ||
<tr> | ||
<td> | ||
@(puzzle.SortOrder + 1) | ||
</td> | ||
<td> | ||
@(puzzle.Puzzle.Name) | ||
</td> | ||
<td> | ||
@(puzzle.SolveCount) | ||
</td> | ||
@* TODO: Highlight the cell if this is your team's ID Same for second and third place. *@ | ||
<td> | ||
@if (puzzle.Fastest.Length >= 1) | ||
{ | ||
<text>@puzzle.Fastest[0].Name (@puzzle.Fastest[0].Time)</text> | ||
} | ||
</td> | ||
<td> | ||
@if (puzzle.Fastest.Length >= 2) | ||
{ | ||
<text>@puzzle.Fastest[1].Name (@puzzle.Fastest[1].Time)</text> | ||
} | ||
</td> | ||
<td> | ||
@if (puzzle.Fastest.Length >= 3) | ||
{ | ||
<text>@puzzle.Fastest[2].Name (@puzzle.Fastest[2].Time)</text> | ||
} | ||
</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using ServerCore.DataModel; | ||
using ServerCore.ModelBases; | ||
|
||
namespace ServerCore.Pages.Events | ||
{ | ||
public class FastestSolvesModel : EventSpecificPageModel | ||
{ | ||
private readonly ServerCore.Models.PuzzleServerContext _context; | ||
|
||
public List<PuzzleStats> Puzzles { get; private set; } | ||
|
||
public FastestSolvesModel(ServerCore.Models.PuzzleServerContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public async Task OnGetAsync() | ||
{ | ||
// get the page data: puzzle, solve count, top three fastest | ||
var puzzlesData = await PuzzleStateHelper.GetSparseQuery(_context, this.Event, null, null) | ||
.Where(s => s.SolvedTime != null && s.Puzzle.IsPuzzle) | ||
.GroupBy(state => state.Puzzle) | ||
.Select(g => new { | ||
Puzzle = g.Key, | ||
SolveCount = g.Count(), | ||
Fastest = g.OrderBy(s => s.SolvedTime - s.UnlockedTime).Take(3).Select(s => new { s.Team.ID, s.Team.Name, Time = s.SolvedTime - s.UnlockedTime}) | ||
}) | ||
.OrderByDescending(p => p.SolveCount).ThenBy(p => p.Puzzle.Name) | ||
.ToListAsync(); | ||
|
||
var puzzles = new List<PuzzleStats>(puzzlesData.Count); | ||
for (int i = 0; i < puzzlesData.Count; i++) | ||
{ | ||
var data = puzzlesData[i]; | ||
var stats = new PuzzleStats() | ||
{ | ||
Puzzle = data.Puzzle, | ||
SolveCount = data.SolveCount, | ||
SortOrder = i, | ||
Fastest = data.Fastest.Select(f => new FastRecord() { ID = f.ID, Name = f.Name, Time = f.Time }).ToArray() | ||
}; | ||
|
||
puzzles.Add(stats); | ||
} | ||
|
||
this.Puzzles = puzzles; | ||
} | ||
|
||
public class PuzzleStats | ||
{ | ||
public Puzzle Puzzle; | ||
public int SolveCount; | ||
public int SortOrder; | ||
public FastRecord[] Fastest; | ||
} | ||
|
||
public class FastRecord | ||
{ | ||
public int ID; | ||
public string Name; | ||
public TimeSpan? Time; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
@page "/{eventId}/Events/Map" | ||
@model ServerCore.Pages.Events.MapModel | ||
|
||
@{ | ||
ViewData["Title"] = "Puzzle State Map"; | ||
} | ||
|
||
<h2>Puzzle State Map</h2> | ||
|
||
<table class="table table-condensed ph-statemap"> | ||
<thead> | ||
<tr> | ||
<th> | ||
Rank | ||
</th> | ||
<th> | ||
@Html.DisplayNameFor(model => model.Teams[0].Team.Name) | ||
</th> | ||
<th> | ||
Puzzles | ||
</th> | ||
<th> | ||
@Html.DisplayNameFor(model => model.Teams[0].Score) | ||
</th> | ||
@foreach (var puzzle in Model.Puzzles) | ||
{ | ||
<th> | ||
<a asp-page="/Puzzles/Status" asp-route-id="@puzzle.Puzzle.ID">@(puzzle.Puzzle.Name) (@puzzle.SolveCount)</a> | ||
</th> | ||
} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@for (int y = 0; y < Model.Teams.Count; y++) { | ||
var team = Model.Teams[y]; | ||
<tr> | ||
<td> | ||
@(team.Rank) | ||
</td> | ||
<td> | ||
<a asp-page="/Teams/Status" asp-route-id="@team.Team.ID">@(team.Team.Name)</a> | ||
</td> | ||
<td> | ||
@Html.DisplayFor(modelItem => team.SolveCount) | ||
</td> | ||
<td> | ||
@Html.DisplayFor(modelItem => team.Score) | ||
</td> | ||
@for (int x = 0; x < Model.Puzzles.Count; x++) | ||
{ | ||
var teamState = Model.StateMap[x, y] ?? MapModel.StateStats.Default; | ||
|
||
<td @if(teamState.DisplayLightness < 30) { <text> class= "dark"</text> } style="background-color: hsl(@teamState.DisplayHue, 100%, @teamState.DisplayLightness%)"> | ||
<a href="">@teamState.DisplayText</a> | ||
</td> | ||
} | ||
</tr> | ||
} | ||
</tbody> | ||
</table> |
Oops, something went wrong.