ProjectLighthouse/ProjectLighthouse/Pages/Debug/RoomVisualizerPage.cshtml
2022-02-17 16:23:09 -05:00

82 lines
No EOL
2.7 KiB
Text

@page "/debug/roomVisualizer"
@using LBPUnion.ProjectLighthouse.Helpers
@using LBPUnion.ProjectLighthouse.Types
@using LBPUnion.ProjectLighthouse.Types.Match
@model LBPUnion.ProjectLighthouse.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>())
{
if (version == GameVersion.LittleBigPlanet1 || version == GameVersion.LittleBigPlanetPSP || version == GameVersion.Unknown) continue;
FindBestRoomResponse? response = RoomHelper.FindBestRoom(null, version, 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.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()on paltform @room.RoomPlatform</p>
<p>Slot type: @room.Slot.SlotType, slot id: @room.Slot.SlotId</p>
@foreach (User player in room.Players)
{
<div class="ui segment">@player.Username</div>
}
</div>
}