示例#1
0
        public void CalcuteScore(ILobby lobby)
        {
            var player       = lobby.Players.SingleOrDefault(entity => entity.Token.Equals(Token));
            var votes        = lobby.VoteResults.SingleOrDefault(vote => vote.Id.Equals(player.Card)).Count;
            var canCalculate = true;

            if (Token.Equals(lobby.MainPlayer))
            {
                if (votes.Equals(0))
                {
                    Points      -= 2;
                    canCalculate = false;
                }
                if (votes.Equals(lobby.Players.Count - 1))
                {
                    Points      -= 3;
                    canCalculate = false;
                }
                if (Points < 0)
                {
                    Points = 0;
                }
            }
            if (canCalculate)
            {
                Points += votes;
            }
        }
示例#2
0
 /// <summary>
 /// Used to request rolls
 /// </summary>
 /// <param name="user">IRC username</param>
 /// <param name="message">Message to send after calling <see cref="ChatRequest.Request"/>, leave empty or null to not send</param>
 public RollRequest(ILobby lobby, string user, string message = null) : base(lobby)
 {
     Message = message;
     User    = user;
     Min     = 0;
     Max     = 100;
 }
        /// <summary>
        /// Constructs a join lobby acknowledged message
        /// </summary>
        /// <param name="lobby">Lobby being acknowledged</param>
        public JoinLobbyAcknowledgedMessageData(ILobby lobby) : base(Naming.GetMessageTypeNameFromMessageDataType <JoinLobbyAcknowledgedMessageData>())
        {
            if (lobby == null)
            {
                throw new ArgumentNullException(nameof(lobby));
            }
            if (!lobby.IsValid)
            {
                throw new ArgumentException("Lobby is not valid.", nameof(lobby));
            }
            Dictionary <string, object> game_mode_rules = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> game_mode_rule in lobby.GameModeRules)
            {
                if (game_mode_rule.Value == null)
                {
                    throw new ArgumentException($"Value of game mode rule key \"{ game_mode_rule.Key }\" is null", nameof(lobby));
                }
                game_mode_rules.Add(game_mode_rule.Key, game_mode_rule.Value);
            }
            Rules     = new LobbyRulesData(lobby.LobbyCode, lobby.Name, lobby.GameMode, lobby.IsPrivate, lobby.MinimalUserCount, lobby.MaximalUserCount, lobby.IsStartingGameAutomatically, game_mode_rules);
            OwnerGUID = lobby.Owner.GUID;
            Users     = new List <UserData>();
            foreach (IUser user in lobby.Users.Values)
            {
                if (user == null)
                {
                    throw new ArgumentException($"Lobby contains null users.", nameof(lobby));
                }
                Users.Add(new UserData(user.GUID, user.GameColor, user.Name, user.LobbyColor));
            }
        }
示例#4
0
        private async Task NextTurn(IGameService game, ILobby lobby)
        {
            var player = game.NextTurn();
            var turn   = game.GetTurn(player);

            await Clients.Group($"lobby-{lobby.Id}").SendAsync("game:next-turn", player.ConnectionId, turn.ToString());
        }
        /// <summary>
        /// Initialise the lobby for a guest.
        /// </summary>
        /// <param name="username">The user's identifier.</param>
        /// <param name="address">The ip address.</param>
        private async Task InitialiseGuest(string username, string address)
        {
            // Connect to host
            _lobby = new Lobby();

            try
            {
                await _lobby.ConnectAsync(address, username);
            }
            catch (Exception e)
            {
                Window window = new MainWindow();
                window.Show();
                this.Close();
                MessageBox.Show("Connection refused!",
                                "HideNSeek",
                                MessageBoxButton.OK,
                                MessageBoxImage.Error);

#if DEBUG
                Console.WriteLine(e.Message);
#endif
            }

            // Configure player listbox
            lBoxPlayers.Items.Add($"YOU: {username}");
            // _host.Lobby.PlayerConnected += (Player player) => { lBoxPlayers.Items.Add(player.PlayerName); };

            // Configure buttons
            btnDisconnect.Content = "Disconnect";
            btnStart.IsEnabled    = false;

            // Configure address label
            lbAddress.Content = address;
        }
示例#6
0
 public Program(IScreen screen, IStateMachine stateMachine, ILobby lobby, IGame game)
 {
     _screen       = screen;
     _stateMachine = stateMachine;
     _lobby        = lobby;
     _game         = game;
 }
        public async Task AddToLobby(IUser user, ILobby lobby, Guid lobbyId)
        {
            user.SetLobbyContext(lobbyId);
            await lobby.AddUserToLobby(user);

            lobby.StartLobby();
            await user.SendMessage($"Joining: {FormatLobbyInfo(lobby)}\n");
        }
 public DataProcessor(IInvokable invoke, INotifiable notify, ILobby lobby) {
     if(invoke != null)
         _invokable = new Invokable(invoke);
     if(notify != null)
         _notifiable = new Notifiable(notify);
     if (lobby != null)
         _lobby = new Lobby(lobby);
 }
示例#9
0
 /// <summary>
 /// Creates a new lobby with URIs asynchronously
 /// </summary>
 /// <param name="httpHostURI">HTTP host URI</param>
 /// <param name="webSocketHostURI">WebSocket host URI</param>
 /// <param name="isConnectionSecure">Is connection secure</param>
 /// <param name="username">Username</param>
 /// <param name="language">Language</param>
 /// <param name="isLobbyPublic">Is lobby public</param>
 /// <param name="maximalPlayerCount">Maximal player count</param>
 /// <param name="drawingTime">Drawing time</param>
 /// <param name="roundCount">Round count</param>
 /// <param name="customWordsString">Custom words string</param>
 /// <param name="customWordsChance">Custom words chance</param>
 /// <param name="isVotekickingEnabled">Is votekicking enabled</param>
 /// <param name="clientsPerIPLimit">Clients per IP limit</param>
 /// <returns>Lobby task</returns>
 private async Task<ILobby> CreateLobbyWithURIsAsync(Uri httpHostURI, Uri webSocketHostURI, bool isConnectionSecure, string username, ELanguage language, bool isLobbyPublic, uint maximalPlayerCount, ulong drawingTime, uint roundCount, string customWordsString, uint customWordsChance, bool isVotekickingEnabled, uint clientsPerIPLimit)
 {
     ILobby ret = null;
     ResponseWithUserSessionCookie<CreateLobbyResponseData> response_with_user_session_cookie = await SendHTTPPostRequestAsync<CreateLobbyResponseData>(new Uri(httpHostURI, "/v1/lobby"), new Dictionary<string, string>
     {
         { "username", username },
         { "language", Naming.GetLanguageString(language) },
         { "public", isLobbyPublic.ToString().ToLower() },
         { "max_players", maximalPlayerCount.ToString() },
         { "drawing_time", drawingTime.ToString() },
         { "rounds", roundCount.ToString() },
         { "custom_words", customWordsString },
         { "custom_words_chance", customWordsChance.ToString() },
         { "enable_votekick", isVotekickingEnabled.ToString().ToLower() },
         { "clients_per_ip_limit", clientsPerIPLimit.ToString() }
     });
     CreateLobbyResponseData response = response_with_user_session_cookie.Response;
     if ((response != null) && response.IsValid)
     {
         ClientWebSocket client_web_socket = new ClientWebSocket();
         client_web_socket.Options.Cookies = cookieContainer;
         await client_web_socket.ConnectAsync(new Uri(webSocketHostURI, $"/v1/ws?lobby_id={ Uri.EscapeUriString(response.LobbyID) }"), default);
         if (client_web_socket.State == WebSocketState.Open)
         {
             ret = new Lobby
             (
                 client_web_socket,
                 isConnectionSecure,
                 response.LobbyID,
                 response.MinimalDrawingTime,
                 response.MaximalDrawingTime,
                 response.MinimalRoundCount,
                 response.MaximalRoundCount,
                 response.MinimalMaximalPlayerCount,
                 response.MaximalMaximalPlayerCount,
                 response.MinimalClientsPerIPLimit,
                 response.MaximalClientsPerIPLimit,
                 response.MaximalPlayerCount,
                 response.CurrentMaximalRoundCount,
                 response.IsLobbyPublic,
                 response.IsVotekickingEnabled,
                 response.CustomWordsChance,
                 response.AllowedClientsPerIPCount,
                 response.DrawingBoardBaseWidth,
                 response.DrawingBoardBaseHeight,
                 response.MinimalBrushSize,
                 response.MaximalBrushSize,
                 response.SuggestedBrushSizes,
                 (Color)response.CanvasColor
             );
         }
         else
         {
             client_web_socket.Dispose();
         }
     }
     return ret;
 }
    public CommunicationHandler(TcpClient serverCon, IErrorHandler error, IInvokable invoke, INotifiable notify, ILobby lobby) {
        _errorHandler = error;
        _tcpClient = serverCon;
        _tcpClient.DataReceived += TcpClient_DataReceived;
        _tcpClient.Disconnected += TcpClient_Disconnnected; 
        _tcpClient.Start();

        _processor = new DataProcessor(invoke, notify, lobby);
    }
示例#11
0
 public bool AddLobby(ILobby lobby)
 {
     if (!LobbyIdIsUnique(lobby.Id.ToString()))
     {
         return(false);
     }
     _lobbies.Add(lobby.Id.ToString(), lobby);
     return(true);
 }
示例#12
0
文件: Main.cs 项目: Blade12629/Skybot
        public Main(ILobby lobby, IEventRunner eventRunner, IDiscordHandler discord, ISpreadsheet sheet, ScriptInput input) : base(eventRunner)
        {
            _lobby       = lobby;
            _discord     = discord;
            _eventRunner = eventRunner;
            _sheet       = sheet;
            _input       = input;

            _sorter = new LobbySort(eventRunner, lobby, input.CaptainA, input.CaptainB);
        }
示例#13
0
        private static void AddId(ILobby l)
        {
            var id = Base64.Random();

            if (!Server.Instance.LobbyIdIsUnique(id.ToString()))
            {
                AddId(l);
            }
            l.Id = id;
        }
示例#14
0
 public LobbyCoordinator(ILobby deafultLobby, LobbyCoordinatorCommandProcessor lobbyCoordinatorCommandProcessor)
 {
     _lobbyCoordinatorCommandProcessor = lobbyCoordinatorCommandProcessor;
     deafultLobby.StartLobby();
     _deafultLobbyId = deafultLobby.GetLobbyId();
     _lobbies        = new List <ILobby>
     {
         deafultLobby
     };
 }
示例#15
0
        public Game(ILobby lobby)
        {
            StartTime = DateTime.Now;
            ID        = lobby.Id;
            _players  = lobby.GetAllPlayers();

            PlayerOrder = Permutation.Random(_players.Count);

            Settings = lobby.Settings;
            _grid    = new Grid(Settings.GridSize, Settings.GridSize);
            _referee = new LineReferee(Settings.WinChainLength);
        }
示例#16
0
        List <ServerFrame> allHistoryFrames = new List <ServerFrame>(); //所有的历史帧


        #region  life cycle

        public void DoStart(int type, int roomId, ILobby server, int size, string name)
        {
            this.RoomId         = roomId;
            this.MaxPlayerCount = size;
            this.name           = name;
            _lobby              = server;
            Tick                = 0;
            TypeId              = type;
            timeSinceLoaded     = 0;
            firstFrameTimeStamp = 0;
            RegisterMsgHandlers();
        }
示例#17
0
        public LobbyViewModel(ILobby lobby)
        {
            if (lobby == null)
                throw new ArgumentNullException(nameof(lobby));

            this.lobby = lobby;

            foreach (var player in lobby.Players)
                Players.Add(player);

            lobby.PlayerJoined += Lobby_PlayerJoined;
            lobby.PlayerLeft += Lobby_PlayerLeft;
        }
示例#18
0
 public SecondStageData(ILobby lobby)
 {
     Stage       = lobby.Stage;
     Text        = lobby.Text;
     DonePlayers = new List <string>();
     foreach (var player in lobby.Players)
     {
         if (player.Ready)
         {
             DonePlayers.Add(player.Token);
         }
     }
 }
示例#19
0
        public bool AddLobby(ILobby lobby)
        {
            if (lobbies.ContainsKey(lobby.Id))
            {
                logger.Error("Failed to add a lobby - lobby with same id already exists");
                return(false);
            }

            lobbies.Add(lobby.Id, lobby);

            lobby.OnDestroyedEvent += OnLobbyDestroyed;
            return(true);
        }
示例#20
0
 /// <summary>
 /// Enters a lobby with URIs asynchronously
 /// </summary>
 /// <param name="httpHostURI">HTTP host URI</param>
 /// <param name="webSocketHostURI">WebSocket host URI</param>
 /// <param name="isConnectionSecure">Is connection secure</param>
 /// <param name="lobbyID">Lobby ID</param>
 /// <param name="username">Username</param>
 /// <returns>Lobby task</returns>
 private async Task<ILobby> EnterLobbyWithURIsAsync(Uri httpHostURI, Uri webSocketHostURI, bool isConnectionSecure, string lobbyID, string username)
 {
     ILobby ret = null;
     ResponseWithUserSessionCookie<EnterLobbyResponseData> response_with_user_session_cookie = await SendHTTPPostRequestAsync<EnterLobbyResponseData>(new Uri(httpHostURI, $"/v1/lobby/player?lobby_id={ Uri.EscapeUriString(lobbyID) }"), new Dictionary<string, string>
     {
         { "lobby_id", lobbyID },
         { "username", username }
     });
     EnterLobbyResponseData response = response_with_user_session_cookie.Response;
     if ((response != null) && response.IsValid)
     {
         ClientWebSocket client_web_socket = new ClientWebSocket();
         client_web_socket.Options.Cookies = cookieContainer;
         await client_web_socket.ConnectAsync(new Uri(webSocketHostURI, $"/v1/ws?lobby_id={ Uri.EscapeUriString(response.LobbyID) }"), default);
         if (client_web_socket.State == WebSocketState.Open)
         {
             ret = new Lobby
             (
                 client_web_socket,
                 isConnectionSecure,
                 response.LobbyID,
                 response.MinimalDrawingTime,
                 response.MaximalDrawingTime,
                 response.MinimalRoundCount,
                 response.MaximalRoundCount,
                 response.MinimalMaximalPlayerCount,
                 response.MaximalMaximalPlayerCount,
                 response.MinimalClientsPerIPLimit,
                 response.MaximalClientsPerIPLimit,
                 response.MaximalPlayerCount,
                 response.CurrentMaximalRoundCount,
                 response.IsLobbyPublic,
                 response.IsVotekickingEnabled,
                 response.CustomWordsChance,
                 response.AllowedClientsPerIPCount,
                 response.DrawingBoardBaseWidth,
                 response.DrawingBoardBaseHeight,
                 response.MinimalBrushSize,
                 response.MaximalBrushSize,
                 response.SuggestedBrushSizes,
                 (Color)response.CanvasColor
             );
         }
         else
         {
             client_web_socket.Dispose();
         }
     }
     return ret;
 }
示例#21
0
        /// <summary>
        /// Constructs a message informing changes in lobby rules
        /// </summary>
        /// <param name="lobby">Lobby</param>
        public LobbyRulesChangedMessageData(ILobby lobby) : base(Naming.GetMessageTypeNameFromMessageDataType <LobbyRulesChangedMessageData>())
        {
            Dictionary <string, object> game_mode_rules = new Dictionary <string, object>();

            foreach (KeyValuePair <string, object> game_mode_rule in lobby.GameModeRules)
            {
                if (game_mode_rule.Value == null)
                {
                    throw new ArgumentException($"Value of game mode rule key \"{ game_mode_rule.Key }\" is null.", nameof(lobby));
                }
                game_mode_rules.Add(game_mode_rule.Key, game_mode_rule.Value);
            }
            Rules = new LobbyRulesData(lobby.LobbyCode, lobby.Name, lobby.GameMode, lobby.IsPrivate, lobby.MinimalUserCount, lobby.MaximalUserCount, lobby.IsStartingGameAutomatically, game_mode_rules);
        }
示例#22
0
        /// <summary>
        /// A slot sorter that sorts by a string list
        /// </summary>
        /// <param name="slotOrder">Slots in order, use irc nicknames</param>
        public SlotSorter(ILobby lobby, string[] slotOrder)
        {
            if (slotOrder == null)
            {
                throw new ArgumentNullException(nameof(slotOrder), "slotOrder cannot be null");
            }
            else if (slotOrder.Length == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(slotOrder), "slotOrder cannot be empty");
            }

            _lobby     = lobby;
            _slotOrder = slotOrder;
            _data      = lobby.LobbyData;
        }
        public BoolResponseBox cleanUpGame(Guid guidForGame, ILobby lobby)
        {
            MonopolyDeal GameToCleanUp = null;
            foreach (MonopolyDeal md in games)
            {
                if (md.MONOPOLY_DEAL_GAME_GUID.CompareTo(guidForGame) == 0)
                {
                    GameToCleanUp = md;
                    break;
                }
            }
            GameToCleanUp.Dispose();

            return new BoolResponseBox(false, "Game not cleaned up");
        }
        public IActionResult TilslutLobby(LobbyViewModel model)
        {
            var    currentuser    = _userSession.User;
            ILobby concreateLobby = _lobbyProxy.JoinLobbyAsync(model.Id, currentuser.Username, currentuser.Password).Result;

            if (concreateLobby != null)
            {
                LobbyViewModel updatedModel = new LobbyViewModel();

                updatedModel.Id        = concreateLobby.Id;
                updatedModel.Admin     = concreateLobby.AdminUserName;
                updatedModel.Usernames = concreateLobby.Usernames.ToList();
                return(RedirectToAction("Lobby", updatedModel));
            }
            return(RedirectToAction("TilslutLobby"));
        }
示例#25
0
        public BoolResponseBox cleanUpGame(Guid guidForGame, ILobby lobby)
        {
            MonopolyDeal GameToCleanUp = null;

            foreach (MonopolyDeal md in games)
            {
                if (md.MONOPOLY_DEAL_GAME_GUID.CompareTo(guidForGame) == 0)
                {
                    GameToCleanUp = md;
                    break;
                }
            }
            GameToCleanUp.Dispose();

            return(new BoolResponseBox(false, "Game not cleaned up"));
        }
示例#26
0
        /// <summary>
        /// Join multiplayer lobby (asynchronous)
        /// </summary>
        /// <param name="host">Host</param>
        /// <param name="port">Port</param>
        /// <param name="username">Username</param>
        /// <param name="teamName">Team name</param>
        /// <returns></returns>
        public static Task <ILobby> JoinMultiplayerLobbyAsync(string host, ushort port, string username, string teamName)
        {
            Task <ILobby> ret = new Task <ILobby>(() =>
            {
                ILobby lobby = null;
                ClientConnection client_connection = Connector.ConnectClientAsync(host, port, username, teamName).GetAwaiter().GetResult();
                if (client_connection != null)
                {
                    lobby = new MultiplayerLobby(client_connection);
                }
                return(lobby);
            });

            ret.Start();
            return(ret);
        }
示例#27
0
 public ThirdStageData(ILobby lobby)
 {
     Stage       = lobby.Stage;
     DonePlayers = new List <string>();
     Cards       = new List <int>();
     foreach (var player in lobby.Players)
     {
         if (player.Ready)
         {
             DonePlayers.Add(player.Token);
             if (!player.Cards.Equals(0))
             {
                 Cards.Add(player.Card);
             }
         }
     }
 }
示例#28
0
        /// <summary>
        /// Creates a new MonopolyDeal Game
        /// </summary>
        /// <param name="playersP">List of PlayerModels</param>
        public MonopolyDeal(List <PlayerModel> playersP, Guid thisGameGuidP, ILobby lobby)
        {
            this.lobby = lobby;
            //Assign Guid to this game of Monopoly Deal
            MONOPOLY_DEAL_GAME_GUID = thisGameGuidP;
            gameModelGuid           = thisGameGuidP;
            //Assign Players to this game of Monopoly Deal
            players = playersP;

            gameStateManager = new GameStateManagerToMoveAdapter(this);

            addPlayersToIDLookup(playersP);
            initialState = createInitialState(players);
            gameStates.Add(initialState);
            currentState = initialState;
            //State added to gameStates list, notify all players, wait for responses
        }
        public IActionResult Lobby(LobbyViewModel model)
        {
            //get the user
            var currentUser = _userSession.User;

            //get the concreate lobby again
            ILobby thisLobby = _lobbyProxy.RequestInstanceAsync(model.Id, currentUser.Username, currentUser.Password).Result;

            //make the model
            LobbyViewModel thisModel = new LobbyViewModel();

            thisModel.Admin     = thisLobby.AdminUserName;
            thisModel.Id        = thisLobby.Id;
            thisModel.Usernames = thisLobby.Usernames.ToList();

            return(View(thisModel));
        }
示例#30
0
        /// <summary>
        /// Creates a new MonopolyDeal Game
        /// </summary>
        /// <param name="playersP">List of PlayerModels</param>
        public MonopolyDeal(List<PlayerModel> playersP, Guid thisGameGuidP, ILobby lobby)
        {
            this.lobby = lobby;
            //Assign Guid to this game of Monopoly Deal
            MONOPOLY_DEAL_GAME_GUID = thisGameGuidP;
            gameModelGuid = thisGameGuidP;
            //Assign Players to this game of Monopoly Deal
            players = playersP;

            gameStateManager = new GameStateManagerToMoveAdapter(this);

            addPlayersToIDLookup(playersP);
            initialState = createInitialState(players);
            gameStates.Add(initialState);
            currentState = initialState;
            //State added to gameStates list, notify all players, wait for responses
        }
        public FourthStageData(ILobby lobby, string playerToken)
        {
            Stage = lobby.Stage;
            var players       = lobby.Players;
            var currentPlayer = players.SingleOrDefault(player => player.Token.Equals(playerToken));

            currentPlayer.Ready = true;
            MainCard            = lobby.Players.SingleOrDefault(player => player.Token.Equals(lobby.MainPlayer)).Card;
            DonePlayers         = new List <string>();
            VoteResult          = lobby.VoteResults;
            foreach (var player in players)
            {
                if (player.Ready)
                {
                    DonePlayers.Add(player.Token);
                }
            }
            lobby.TryGoToNextStageAsync();
        }
示例#32
0
        private void txtIO_TextChanged(object sender, EventArgs e)
        {
            if (!this.textChangingFromNetwork && this.textBoxMap[(TextBox)sender] == this.lastKnownIdOfThisPeer)
            {
                /// Get an interface for sending the message
                ILobby sendIface = null;
                if (this.joinedLobby != null && this.createdLobby == null)
                {
                    sendIface = this.joinedLobby;
                }
                else if (this.joinedLobby == null && this.createdLobby != null)
                {
                    sendIface = this.createdLobby;
                }

                if (sendIface != null)
                {
                    /// Create the package
                    RCPackage package = RCPackage.CreateNetworkCustomPackage(MY_FORMAT);
                    package.WriteString(0, ((TextBox)sender).Text);

                    /// Get the targets of the package
                    List <int> targets = new List <int>();
                    for (int i = 0; i < this.lastKnownLineStates.Length; i++)
                    {
                        if (i != this.lastKnownIdOfThisPeer && this.targetSelectors[i].Checked)
                        {
                            targets.Add(i);
                        }
                    }
                    if (targets.Count != 0)
                    {
                        /// Send a dedicated message.
                        sendIface.SendPackage(package, targets.ToArray());
                    }
                    else
                    {
                        /// Send the message to the whole lobby.
                        sendIface.SendPackage(package);
                    }
                }
            }
        }
示例#33
0
        public IWrapper MapToStageData(string playerToken, ILobby lobby)
        {
            IWrapper lobbyData;

            switch (lobby.Stage)
            {
            case 2: lobbyData = new SecondStageData(lobby);
                break;

            case 3: lobbyData = new ThirdStageData(lobby);
                break;

            case 4: lobbyData = new FourthStageData(lobby, playerToken);
                break;

            default: lobbyData = new FirstStageData(lobby, playerToken);
                break;
            }
            return(lobbyData);
        }
示例#34
0
 public bool createGame(List <LobbyClient> clients, Guid guidForGame, ILobby lobby)
 {
     try
     {
         List <PlayerModel> playersMD = new List <PlayerModel>();
         foreach (LobbyClient lc in clients)
         {
             PlayerModel p = new PlayerModel(lc.getName());
             p.guid = lc.getGuid();
             p.isReadyToStartGame = true;
             playersMD.Add(p);
         }
         MonopolyDeal game = new MonopolyDeal(playersMD, guidForGame, lobby);
         games.Add(game);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 public bool createGame(List<LobbyClient> clients, Guid guidForGame, ILobby lobby)
 {
     try
     {
         List<PlayerModel> playersMD = new List<PlayerModel>();
         foreach (LobbyClient lc in clients)
         {
             PlayerModel p = new PlayerModel(lc.getName());
             p.guid = lc.getGuid();
             p.isReadyToStartGame = true;
             playersMD.Add(p);
         }
         MonopolyDeal game = new MonopolyDeal(playersMD, guidForGame, lobby);
         games.Add(game);
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
示例#36
0
 /// <summary>
 /// Enters a lobby asynchronously
 /// </summary>
 /// <param name="lobbyID">Lobby ID</param>
 /// <param name="username">Username</param>
 /// <returns>Lobby task</returns>
 public async Task<ILobby> EnterLobbyAsync(string lobbyID, string username)
 {
     if (lobbyID == null)
     {
         throw new ArgumentNullException(nameof(lobbyID));
     }
     if (username == null)
     {
         throw new ArgumentNullException(nameof(username));
     }
     if (username.Length > Rules.maximalUsernameLength)
     {
         throw new ArgumentException($"Username must be atleast { Rules.maximalUsernameLength } characters long.");
     }
     ILobby ret = await EnterLobbyWithURIsAsync(HTTPHostURI, WebSocketHostURI, IsUsingSecureProtocols, lobbyID, username);
     if ((ret == null) && IsUsingSecureProtocols && IsAllowedToUseInsecureConnections)
     {
         ret = await EnterLobbyWithURIsAsync(InsecureHTTPHostURI, InsecureWebSocketHostURI, false, lobbyID, username);
     }
     return ret;
 }
示例#37
0
 public Lobby(ILobby lobby) {
     _lobby = lobby;
 }