mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-06 02:32:28 +00:00
Add ability to create fake rooms and delete all rooms
This commit is contained in:
parent
643404a7b3
commit
c1e807b29a
2 changed files with 61 additions and 1 deletions
|
@ -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<IActionResult> CreateFakeRoom()
|
||||
{
|
||||
#if !DEBUG
|
||||
return this.NotFound();
|
||||
#else
|
||||
List<User> 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
|
||||
}
|
||||
}
|
|
@ -14,6 +14,14 @@
|
|||
<p>This page will automatically refresh every 5 seconds.</p>
|
||||
<p>@RoomHelper.Rooms.Count rooms</p>
|
||||
|
||||
<a href="/debug/roomVisualizer/createFakeRoom">
|
||||
<div class="ui blue button">Create Fake Room</div>
|
||||
</a>
|
||||
|
||||
<a href="/debug/roomVisualizer/deleteRooms">
|
||||
<div class="ui red button">Nuke all rooms</div>
|
||||
</a>
|
||||
|
||||
<h2>Best rooms for each game version</h2>
|
||||
@foreach (GameVersion version in Enum.GetValues<GameVersion>())
|
||||
{
|
||||
|
@ -29,8 +37,16 @@
|
|||
|
||||
@foreach (Room room in RoomHelper.Rooms)
|
||||
{
|
||||
<div class="ui blue inverted segment">
|
||||
bool userInRoom = room.Players.Select(p => p.Username).Contains(Model.User?.Username);
|
||||
string color = userInRoom ? "green" : "blue";
|
||||
<div class="ui @color inverted segment">
|
||||
<h3>Room @room.RoomId</h3>
|
||||
@if (userInRoom)
|
||||
{
|
||||
<p>
|
||||
<b>You are currently in this room.</b>
|
||||
</p>
|
||||
}
|
||||
<p>@room.Players.Count players, state is @room.State, version is @room.RoomVersion.ToPrettyString()</p>
|
||||
<p>Slot type: @room.Slot.SlotType, slot id: @room.Slot.SlotId</p>
|
||||
@foreach (User player in room.Players)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue