* Ace now lets you play again if there are two players * 1 line if :o * Better Ace * Feature/automautic room closing (#5) * Room now closes when nobody is in the room * cleanup
43 lines
941 B
C#
43 lines
941 B
C#
namespace MauMau_Server.Websockets;
|
|
|
|
public class RoomManager : IRoomManager
|
|
{
|
|
private static readonly Dictionary<string, Room> Rooms = new();
|
|
|
|
public string CreateRoom()
|
|
{
|
|
var roomId = Guid.NewGuid().ToString();
|
|
var room = new Room(this, roomId);
|
|
Rooms.Add(roomId, room);
|
|
return roomId;
|
|
}
|
|
|
|
public Room GetRoom(string roomId)
|
|
{
|
|
return Rooms[roomId];
|
|
}
|
|
|
|
public List<string> GetAllRooms()
|
|
{
|
|
return Rooms.Keys.ToList();
|
|
}
|
|
|
|
public void RemoveRoom(string roomId)
|
|
{
|
|
Rooms.Remove(roomId);
|
|
}
|
|
|
|
public bool RoomExists(string roomId)
|
|
{
|
|
return Rooms.ContainsKey(roomId);
|
|
}
|
|
}
|
|
|
|
public interface IRoomManager
|
|
{
|
|
public string CreateRoom();
|
|
public Room GetRoom(string roomId);
|
|
public List<string> GetAllRooms();
|
|
public void RemoveRoom(string roomId);
|
|
public bool RoomExists(string roomId);
|
|
} |