Game seems to work
This commit is contained in:
@@ -1,39 +1,20 @@
|
||||
using MauMau_Server.Websockets;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MauMau_Server.Room;
|
||||
|
||||
public class RoomMessage
|
||||
public class RoomMessage<T>
|
||||
{
|
||||
public string CurrentRoomType;
|
||||
public string? MessageType;
|
||||
public List<string> JoinedPlayers;
|
||||
public string? Message;
|
||||
|
||||
public RoomMessage(string currentRoomType, IEnumerable<ConnectionInstance> joinedPlayers, string? message)
|
||||
public string Type { get; set; }
|
||||
public string Data { get; set; }
|
||||
|
||||
public RoomMessage(string type, T data)
|
||||
{
|
||||
CurrentRoomType = currentRoomType;
|
||||
JoinedPlayers = GetNamesFromConnections(joinedPlayers);
|
||||
Message = message;
|
||||
Type = type;
|
||||
Data = JsonConvert.SerializeObject(data);
|
||||
}
|
||||
|
||||
public RoomMessage(string currentRoomType, MessageType messageType, IEnumerable<ConnectionInstance> joinedPlayers, string? message)
|
||||
public RoomMessage()
|
||||
{
|
||||
CurrentRoomType = currentRoomType;
|
||||
MessageType = messageType.ToString();
|
||||
JoinedPlayers = GetNamesFromConnections(joinedPlayers);
|
||||
Message = message;
|
||||
|
||||
}
|
||||
|
||||
private static List<string> GetNamesFromConnections(IEnumerable<ConnectionInstance> connections)
|
||||
{
|
||||
return connections.Select(player => player.Name).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public enum MessageType
|
||||
{
|
||||
INFO,
|
||||
SUCCES,
|
||||
WARNING,
|
||||
ERROR
|
||||
}
|
||||
Reference in New Issue
Block a user