public bool TryScore(int score)
        {
            Buzz buzz = this.buzzQueue.Min;

            if (buzz == null)
            {
                // This is a bug we should log when logging is added.
                Debug.Fail($"{nameof(this.TryScore)} should not be called when there are no players in the queue.");
                return(false);
            }

            this.buzzQueue.Remove(buzz);

            // TODO: We may want to limit what score can be, to protect against typos.
            if (!this.scores.TryGetValue(buzz.UserId, out int currentScore))
            {
                currentScore = 0;
            }

            this.scores[buzz.UserId] = currentScore + score;

            ScoreAction action = new ScoreAction(buzz, score);

            this.actions.Push(action);

            return(true);
        }
Exemplo n.º 2
0
        public virtual bool TryScoreBuzz(int score)
        {
            lock (this.collectionLock)
            {
                Buzz buzz = this.GetNextPlayerToPrompt();
                if (buzz == null)
                {
                    // This is a bug we should log when logging is added.
                    Debug.Fail($"{nameof(this.TryScoreBuzz)} should not be called when there are no players in the queue.");
                    return(false);
                }

                this.BuzzQueue.Remove(buzz);

                ScoreAction action = new ScoreAction(buzz, score);
                this.Actions.Push(action);
                this.AlreadyScoredTeamIds.Add(GetTeamId(buzz));
                return(true);
            }
        }