diff --git a/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs b/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs new file mode 100644 index 00000000..3747de64 --- /dev/null +++ b/ProjectLighthouse/Controllers/Website/Debug/RoomVisualizerController.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using LBPUnion.ProjectLighthouse.Helpers; +using LBPUnion.ProjectLighthouse.Types; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace LBPUnion.ProjectLighthouse.Controllers.Website.Debug; + +[ApiController] +[Route("debug/roomVisualizer")] +public class RoomVisualizerController : ControllerBase +{ + private readonly Database database; + + public RoomVisualizerController(Database database) + { + this.database = database; + } + + [HttpGet("createFakeRoom")] + public async Task CreateFakeRoom() + { + #if !DEBUG + return this.NotFound(); + #else + List users = await this.database.Users.OrderByDescending(_ => EF.Functions.Random()).Take(2).ToListAsync(); + RoomHelper.CreateRoom(users, GameVersion.LittleBigPlanet2); + return this.Redirect("/debug/roomVisualizer"); + #endif + } + + [HttpGet("deleteRooms")] + public IActionResult DeleteRooms() + { + #if !DEBUG + return this.NotFound(); + #else + RoomHelper.Rooms.RemoveAll(_ => true); + return this.Redirect("/debug/roomVisualizer"); + #endif + } +} \ No newline at end of file diff --git a/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml b/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml index 72c3e2e0..17217109 100644 --- a/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml +++ b/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml @@ -14,6 +14,14 @@

This page will automatically refresh every 5 seconds.

@RoomHelper.Rooms.Count rooms

+ +
Create Fake Room
+
+ + +
Nuke all rooms
+
+

Best rooms for each game version

@foreach (GameVersion version in Enum.GetValues()) { @@ -29,8 +37,16 @@ @foreach (Room room in RoomHelper.Rooms) { -
+ bool userInRoom = room.Players.Select(p => p.Username).Contains(Model.User?.Username); + string color = userInRoom ? "green" : "blue"; +

Room @room.RoomId

+ @if (userInRoom) + { +

+ You are currently in this room. +

+ }

@room.Players.Count players, state is @room.State, version is @room.RoomVersion.ToPrettyString()

Slot type: @room.Slot.SlotType, slot id: @room.Slot.SlotId

@foreach (User player in room.Players)