Show best room in room visualizer

This commit is contained in:
jvyden 2022-01-16 18:24:41 -05:00
commit 643404a7b3
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 22 additions and 3 deletions

View file

@ -24,7 +24,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
internal static int RoomIdIncrement => roomIdIncrement++;
public static FindBestRoomResponse? FindBestRoom(User? user, GameVersion roomVersion, string location)
public static FindBestRoomResponse? FindBestRoom(User? user, GameVersion roomVersion, string? location)
{
if (roomVersion == GameVersion.LittleBigPlanet1 || roomVersion == GameVersion.LittleBigPlanetPSP) return null;
@ -64,6 +64,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
// If we got here then it should be a valid room.
FindBestRoomResponse response = new();
response.RoomId = room.RoomId;
response.Players = new List<Player>();
response.Locations = new List<string>();
@ -93,7 +94,10 @@ namespace LBPUnion.ProjectLighthouse.Helpers
);
}
response.Locations.Add(location);
if (location == null)
{
response.Locations.Add(location);
}
response.Slots = new List<List<int>>
{

View file

@ -14,10 +14,23 @@
<p>This page will automatically refresh every 5 seconds.</p>
<p>@RoomHelper.Rooms.Count rooms</p>
<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);
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)
{
<div class="ui blue inverted segment">
<h2>Room @room.RoomId</h2>
<h3>Room @room.RoomId</h3>
<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)

View file

@ -6,6 +6,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Match
{
public class FindBestRoomResponse
{
public int RoomId;
public List<Player> Players { get; set; }
public List<List<int>> Slots { get; set; }