mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-01-22 17:22:15 +00:00
Pong highscore frontend.
This commit is contained in:
parent
73402c31a6
commit
13ad0ff4f3
5 changed files with 114 additions and 0 deletions
44
Project-Unite/Controllers/StatsController.cs
Normal file
44
Project-Unite/Controllers/StatsController.cs
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Project_Unite.Models;
|
||||||
|
|
||||||
|
namespace Project_Unite.Controllers
|
||||||
|
{
|
||||||
|
public class StatsController : Controller
|
||||||
|
{
|
||||||
|
// GET: Stats
|
||||||
|
public ActionResult Pong(int id = 1)
|
||||||
|
{
|
||||||
|
var db = new ApplicationDbContext();
|
||||||
|
var highscores = new List<PongHighscore>();
|
||||||
|
foreach(var user in db.Users)
|
||||||
|
{
|
||||||
|
highscores.Add(new PongHighscore
|
||||||
|
{
|
||||||
|
UserId = user.Id,
|
||||||
|
Level = user.Pong_HighestLevel,
|
||||||
|
CodepointsCashout = user.Pong_HighestCodepointsCashout
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
int pagecount = highscores.GetPageCount(10);
|
||||||
|
if (id > pagecount || id < 1)
|
||||||
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||||
|
|
||||||
|
var pages = highscores.OrderByDescending(x=>x.Level).ToArray().GetItemsOnPage(id, 10);
|
||||||
|
|
||||||
|
var model = new PongStatsViewModel
|
||||||
|
{
|
||||||
|
Highscores = pages,
|
||||||
|
CurrentPage = id,
|
||||||
|
PageCount = 10
|
||||||
|
};
|
||||||
|
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,6 +39,10 @@ public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<Applicat
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Pong_HighestLevel { get; set; }
|
||||||
|
public int Pong_HighestCodepointsCashout { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public ForumPost[] UnreadPosts
|
public ForumPost[] UnreadPosts
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
21
Project-Unite/Models/PongHighscore.cs
Normal file
21
Project-Unite/Models/PongHighscore.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Project_Unite.Models
|
||||||
|
{
|
||||||
|
public class PongHighscore
|
||||||
|
{
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public int CodepointsCashout { get; set; }
|
||||||
|
public int Level { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PongStatsViewModel
|
||||||
|
{
|
||||||
|
public int PageCount { get; set; }
|
||||||
|
public int CurrentPage { get; set; }
|
||||||
|
public List<PongHighscore> Highscores { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -263,6 +263,7 @@
|
||||||
<Compile Include="Controllers\OAuth2Controller.cs" />
|
<Compile Include="Controllers\OAuth2Controller.cs" />
|
||||||
<Compile Include="Controllers\ProfilesController.cs" />
|
<Compile Include="Controllers\ProfilesController.cs" />
|
||||||
<Compile Include="Controllers\SkinsController.cs" />
|
<Compile Include="Controllers\SkinsController.cs" />
|
||||||
|
<Compile Include="Controllers\StatsController.cs" />
|
||||||
<Compile Include="Controllers\WikiControllerController.cs" />
|
<Compile Include="Controllers\WikiControllerController.cs" />
|
||||||
<Compile Include="Global.asax.cs">
|
<Compile Include="Global.asax.cs">
|
||||||
<DependentUpon>Global.asax</DependentUpon>
|
<DependentUpon>Global.asax</DependentUpon>
|
||||||
|
@ -444,6 +445,7 @@
|
||||||
<Compile Include="Models\IdentityModels.cs" />
|
<Compile Include="Models\IdentityModels.cs" />
|
||||||
<Compile Include="Models\ManageViewModels.cs" />
|
<Compile Include="Models\ManageViewModels.cs" />
|
||||||
<Compile Include="Models\Notification.cs" />
|
<Compile Include="Models\Notification.cs" />
|
||||||
|
<Compile Include="Models\PongHighscore.cs" />
|
||||||
<Compile Include="Models\Role.cs" />
|
<Compile Include="Models\Role.cs" />
|
||||||
<Compile Include="Models\SearchModels.cs" />
|
<Compile Include="Models\SearchModels.cs" />
|
||||||
<Compile Include="Models\Skin.cs" />
|
<Compile Include="Models\Skin.cs" />
|
||||||
|
@ -583,6 +585,7 @@
|
||||||
<Content Include="Views\Bugs\ViewCategory.cshtml" />
|
<Content Include="Views\Bugs\ViewCategory.cshtml" />
|
||||||
<Content Include="Views\Bugs\ViewBug.cshtml" />
|
<Content Include="Views\Bugs\ViewBug.cshtml" />
|
||||||
<Content Include="Views\Bugs\PostBug.cshtml" />
|
<Content Include="Views\Bugs\PostBug.cshtml" />
|
||||||
|
<Content Include="Views\Stats\Pong.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
|
42
Project-Unite/Views/Stats/Pong.cshtml
Normal file
42
Project-Unite/Views/Stats/Pong.cshtml
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
@model Project_Unite.Models.PongStatsViewModel
|
||||||
|
@{
|
||||||
|
ViewBag.Title = "Pong - Highscores";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h2>Pong highscores</h2>
|
||||||
|
|
||||||
|
<p>One of the apps in ShiftOS is a recreation of Pong where the game is split into levels that are 60 minutes in length.</p>
|
||||||
|
|
||||||
|
<p>You can earn Codepoints in Pong by either beating the AI, or surviving a level. You can cash out at the end of the level. Just be ware, if the ball gets past you, you lose all those Codepoints.</p>
|
||||||
|
|
||||||
|
<p>Below is a list of everyone's Pong scores - the top players at the top of the list.</p>
|
||||||
|
|
||||||
|
<table class="table-condensed">
|
||||||
|
<tr>
|
||||||
|
<th>User</th>
|
||||||
|
<th>Level</th>
|
||||||
|
<th>Codepoints</th>
|
||||||
|
</tr>
|
||||||
|
@foreach(var entry in Model.Highscores)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Html.UserLink(entry.UserId)</td>
|
||||||
|
<td>@entry.Level</td>
|
||||||
|
<td>@entry.CodepointsCashout CP</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<ul class="pagination">
|
||||||
|
@for(int i = 1; i <= Model.PageCount; i++)
|
||||||
|
{
|
||||||
|
@if (i == Model.CurrentPage)
|
||||||
|
{
|
||||||
|
<li class="active">@Html.ActionLink(i.ToString(), "Pong", "Stats", null, new { id = i })</li>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<li>@Html.ActionLink(i.ToString(), "Pong", "Stats", null, new { id = i })</li>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</ul>
|
Loading…
Reference in a new issue