Example #1
0
        public override Task OnDisconnected(bool stopCalled)
        {
            if (Playing)
            {
                if (CurrentRound.Player.ConnectionId == Context.ConnectionId)
                {
                    if (Players.Values.Where(x => x.Playing).Count() > 1)
                    {
                        CurrentRound.Player = _nextPlayer();
                        Clients.All.RoundUpdate(CurrentRound);
                    }
                    else
                    {
                        // The last player left!
                        Playing = false;
                        RoundHistory.Clear();
                        CurrentRound = null;
                    }
                }

            }
            Players.Remove(Context.ConnectionId);
            _updateLeaderboard();
            return base.OnDisconnected(stopCalled);
        }
Example #2
0
        private void _nextRound()
        {
            if (CurrentRound != null)
            {
                RoundHistory.Add(CurrentRound);
                _updateRoundHistory();
            }
            var startingPlayer = _nextPlayer();
            CurrentRound = new Round();
            CurrentRound.Player = startingPlayer;

            Clients.All.NewRound(CurrentRound);
        }