Game seems to work
This commit is contained in:
@@ -1,39 +1,33 @@
|
||||
using MauMau_Server.Mau;
|
||||
using MauMau_Server.Room.Messages;
|
||||
using MauMau_Server.Websockets;
|
||||
|
||||
namespace MauMau_Server.Room;
|
||||
|
||||
public class Lobby : RoomType
|
||||
{
|
||||
private readonly Room _room;
|
||||
|
||||
public Lobby(Room room)
|
||||
public Lobby(Room room) : base(room)
|
||||
{
|
||||
_room = room;
|
||||
}
|
||||
|
||||
public Lobby(Room room, ConnectionInstance connection)
|
||||
{
|
||||
_room = room;
|
||||
Console.WriteLine(connection.Name + " won the game!");
|
||||
}
|
||||
|
||||
public void OnMessage(ConnectionInstance sender, string message)
|
||||
public override void OnMessage(ConnectionInstance sender, RoomMessage<string> message)
|
||||
{
|
||||
// TODO: Add a way to change game settings
|
||||
if (sender == _room._host)
|
||||
if (message.Type == "LOBBY" && sender == _room.Host)
|
||||
{
|
||||
_room._roomType = new Game(_room, _room.Connections);
|
||||
_room.RoomType = new Game(_room, _room.Connections);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnConnect(ConnectionInstance connection)
|
||||
public override void OnConnect(ConnectionInstance connection)
|
||||
{
|
||||
var roomMessage = new RoomMessage("LOBBY", MessageType.INFO, _room.Connections, connection.Name + " joined!");
|
||||
var joinMessage = new JoinMessage(connection.Id, connection.Name + " has joined the room.");
|
||||
_room.BroadCast(new RoomMessage<JoinMessage>("JOIN", joinMessage));
|
||||
}
|
||||
|
||||
public void OnDisconnect(ConnectionInstance connection)
|
||||
public override void OnDisconnect(ConnectionInstance connection)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var leaveMessage = new LeaveMessage(connection.Id, connection.Name + " has left the room.");
|
||||
_room.BroadCast(new RoomMessage<LeaveMessage>("LEAVE", leaveMessage));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user