ProjectLighthouse/ProjectLighthouse/Extensions/RoomExtensions.cs
2022-05-15 12:04:10 -04:00

25 lines
No EOL
649 B
C#

#nullable enable
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using LBPUnion.ProjectLighthouse.Types;
using LBPUnion.ProjectLighthouse.Types.Match;
namespace LBPUnion.ProjectLighthouse.Extensions;
public static class RoomExtensions
{
public static List<User> GetPlayers(this Room room, Database database)
{
List<User> players = new();
foreach (int playerId in room.PlayerIds)
{
User? player = database.Users.FirstOrDefault(p => p.UserId == playerId);
Debug.Assert(player != null);
players.Add(player);
}
return players;
}
}