ProjectLighthouse/ProjectLighthouse.Servers.Website/Pages/Debug/RoomVisualizerPage.cshtml

86 lines
No EOL
2.9 KiB
Text

@page "/debug/roomVisualizer"
@using LBPUnion.ProjectLighthouse.Extensions
@using LBPUnion.ProjectLighthouse.Helpers
@using LBPUnion.ProjectLighthouse.Match.Rooms
@using LBPUnion.ProjectLighthouse.PlayerData
@using LBPUnion.ProjectLighthouse.PlayerData.Profiles
@using LBPUnion.ProjectLighthouse.Types
@model LBPUnion.ProjectLighthouse.Servers.Website.Pages.Debug.RoomVisualizerPage
@{
Layout = "Layouts/BaseLayout";
Model.Title = "Debug - Room Visualizer";
const int refreshSeconds = 5;
}
<script>
let shouldRefresh = true;
setTimeout(() => {
if (shouldRefresh) window.location.reload();
}, @(refreshSeconds * 1000));
function stopRefreshing() {
shouldRefresh = false;
console.log("Stopped refresh");
const stopRefreshButton = document.getElementById("stop-refresh-button");
stopRefreshButton.parentElement.removeChild(stopRefreshButton);
console.log("Removed stop refresh button");
}
</script>
<p>This page will automatically refresh every @refreshSeconds seconds.</p>
@* workaround for users w/o js*@
<noscript>
<b>You will not be able to disable auto-refresh without JavaScript. Please enable JavaScript for this functionality.</b><br>
<meta http-equiv="refresh" content="@refreshSeconds">
</noscript>
<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>
<button class="ui blue button" onclick="stopRefreshing()" id="stop-refresh-button">Stop refreshing</button>
<h2>Best rooms for each game version</h2>
@foreach (GameVersion version in Enum.GetValues<GameVersion>())
{
#nullable enable
if (version == GameVersion.LittleBigPlanet1 || version == GameVersion.LittleBigPlanetPSP || version == GameVersion.Unknown) continue;
FindBestRoomResponse? response = RoomHelper.FindBestRoom(null, version, null, null, null);
string text = response == null ? "No room found." : "Room " + response.RoomId;
<p><b>Best room for @version.ToPrettyString()</b>: @text</p>
}
<h2>Room display</h2>
@foreach (Room room in RoomHelper.Rooms)
{
bool userInRoom = room.PlayerIds.Contains(Model.User?.UserId ?? -1);
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.PlayerIds.Count players, state is @room.State, version is @room.RoomVersion.ToPrettyString() on platform @room.RoomPlatform</p>
<p>Slot type: @room.Slot.SlotType, slot id: @room.Slot.SlotId</p>
@foreach (User player in room.GetPlayers(Model.Database))
{
<div class="ui segment">@player.Username</div>
}
</div>
}