Example #1
0
        void IServer.HandleUserEnterQueue(IServerUser user, QueueAction action)
        {
            var matchmaking = GetMatchmaking(user, action);

            if (matchmaking == null)
            {
                return;
            }

            lock (matchmaking)
            {
                var regCount = matchmaking.GetRegisterCount(user);
                if (regCount >= _config.MaxQueueCount)
                {
                    user.IllegalAction("Exceeded max queue action: " + _config.MaxQueueCount);
                    return;
                }

                var queueLimitExclusive = Math.Min(_config.MaxQueueCount, regCount + action.Count);
                for (; regCount < queueLimitExclusive; regCount++)
                {
                    matchmaking.EnterQueue(user);
                }

                user.Send(Packet.PacketTypeS2C.QueueState, regCount);
            }
        }
Example #2
0
        private IMatchmaking GetMatchmaking(IServerUser user, QueueAction action)
        {
            if (action.Count <= 0)
            {
                user.IllegalAction("Invalid queue count");
                return(null);
            }

            IMatchmaking matchmaking;

            if (!_matchmaking.TryGetValue(action.GameMode, out matchmaking))
            {
                user.IllegalAction("There is no such gamemode");
                return(null);
            }
            return(matchmaking);
        }
Example #3
0
        void IServer.HandleUserEndTurn(IServerUser user, long gameIdentifier)
        {
            ServerGame game;

            if (!_runningGames.TryGetValue(gameIdentifier, out game))
            {
                user.IllegalAction("You can't end your turn in a game you don't even play in: " + gameIdentifier);
                return;
            }
            game.UserRequestsEndTurn(user);
        }
Example #4
0
        void IServer.HandleUserAction(IServerUser @from, LiveGameAction action)
        {
            ServerGame game;

            if (!_runningGames.TryGetValue(action.GameIdentifier, out game))
            {
                @from.IllegalAction("You cannot take action in a game you don't even play in!");
                return;
            }

            game.AddGameAction(from, action);
        }
Example #5
0
        void IServer.HandleUserResync(IServerUser user, long gameIdentifier)
        {
            ServerGame game;

            if (!_runningGames.TryGetValue(gameIdentifier, out game))
            {
                _logger.LogWarning($"User tried resyncing in an unknown game: {gameIdentifier}");
                user.IllegalAction($"Cannot resync in game: {gameIdentifier}, because it does not exist!");
                return;
            }
            game.HandleReconnect(user);
        }