Exemplo n.º 1
0
        private void HandleStrikeBonus()
        {
            Logger.Info("BowlingPlayer :: HandleStrikeBonus");

            if (BonusLastFramesEvent == null)
            {
                return;
            }

            BonusLastFramesEvent.Invoke();

            if (CurrentFrame.BonusScore.Count < _gameRules.NumberOfBonusRolls &&
                CurrentFrame.BonusScore.Sum(roll => roll.Score) < _gameRules.MaxScore)
            {
                NextPlayerRollEvent();
            }
        }
Exemplo n.º 2
0
        private void NextPlayerRollEvent( )
        {
            Logger.Info("BowlingPlayer :: NextPlayerRollEvent");

            if (_gameRules.IsLastFrame(_currentFrameCounter))
            {
                if (CurrentFrame.IsSpare)
                {
                    if (BonusLastFramesEvent != null)
                    {
                        Logger.Info("BowlingPlayer :: BonusLastFramesEvent");

                        BonusLastFramesEvent.Invoke();
                    }
                }
                if (CurrentFrame.IsStrike)
                {
                    Logger.Info("BowlingPlayer :: HandleStrikeBonus");

                    HandleStrikeBonus();
                }

                if (OnFramesCompleted == null)
                {
                    return;
                }

                Logger.Info("BowlingPlayer :: OnFramesCompleted");

                OnFramesCompleted.Invoke();

                return;
            }

            if (OnFrameComplete != null)
            {
                Logger.Info("BowlingPlayer :: OnFrameComplete");

                OnFrameComplete.Invoke(CurrentFrame);
            }
        }