diff options
| author | Michael <[email protected]> | 2017-05-02 16:03:32 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-02 16:03:32 -0400 |
| commit | 13ad0ff4f3bce05e513768d4999a3f4ec471b872 (patch) | |
| tree | 85c44b6fa88c79d3d91728dcd3aaee190aea9752 | |
| parent | 73402c31a69bec303933d80a0cedaa5ae6a4f89c (diff) | |
| download | project-unite-13ad0ff4f3bce05e513768d4999a3f4ec471b872.tar.gz project-unite-13ad0ff4f3bce05e513768d4999a3f4ec471b872.tar.bz2 project-unite-13ad0ff4f3bce05e513768d4999a3f4ec471b872.zip | |
Pong highscore frontend.
| -rw-r--r-- | Project-Unite/Controllers/StatsController.cs | 44 | ||||
| -rw-r--r-- | Project-Unite/Models/IdentityModels.cs | 4 | ||||
| -rw-r--r-- | Project-Unite/Models/PongHighscore.cs | 21 | ||||
| -rw-r--r-- | Project-Unite/Project-Unite.csproj | 3 | ||||
| -rw-r--r-- | Project-Unite/Views/Stats/Pong.cshtml | 42 |
5 files changed, 114 insertions, 0 deletions
diff --git a/Project-Unite/Controllers/StatsController.cs b/Project-Unite/Controllers/StatsController.cs new file mode 100644 index 0000000..71d2adc --- /dev/null +++ b/Project-Unite/Controllers/StatsController.cs @@ -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); + } + } +}
\ No newline at end of file diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs index e11d675..2e1bf31 100644 --- a/Project-Unite/Models/IdentityModels.cs +++ b/Project-Unite/Models/IdentityModels.cs @@ -39,6 +39,10 @@ namespace Project_Unite.Models } + public int Pong_HighestLevel { get; set; } + public int Pong_HighestCodepointsCashout { get; set; } + + public ForumPost[] UnreadPosts { get diff --git a/Project-Unite/Models/PongHighscore.cs b/Project-Unite/Models/PongHighscore.cs new file mode 100644 index 0000000..374a3b2 --- /dev/null +++ b/Project-Unite/Models/PongHighscore.cs @@ -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; } + } +}
\ No newline at end of file diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index 07bcda5..3f73890 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -263,6 +263,7 @@ <Compile Include="Controllers\OAuth2Controller.cs" /> <Compile Include="Controllers\ProfilesController.cs" /> <Compile Include="Controllers\SkinsController.cs" /> + <Compile Include="Controllers\StatsController.cs" /> <Compile Include="Controllers\WikiControllerController.cs" /> <Compile Include="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> @@ -444,6 +445,7 @@ <Compile Include="Models\IdentityModels.cs" /> <Compile Include="Models\ManageViewModels.cs" /> <Compile Include="Models\Notification.cs" /> + <Compile Include="Models\PongHighscore.cs" /> <Compile Include="Models\Role.cs" /> <Compile Include="Models\SearchModels.cs" /> <Compile Include="Models\Skin.cs" /> @@ -583,6 +585,7 @@ <Content Include="Views\Bugs\ViewCategory.cshtml" /> <Content Include="Views\Bugs\ViewBug.cshtml" /> <Content Include="Views\Bugs\PostBug.cshtml" /> + <Content Include="Views\Stats\Pong.cshtml" /> </ItemGroup> <ItemGroup> <Folder Include="App_Data\" /> diff --git a/Project-Unite/Views/Stats/Pong.cshtml b/Project-Unite/Views/Stats/Pong.cshtml new file mode 100644 index 0000000..c14ed4a --- /dev/null +++ b/Project-Unite/Views/Stats/Pong.cshtml @@ -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>
\ No newline at end of file |
