Belot.Deal.CountDealPoints C# (CSharp) Метод

CountDealPoints() приватный Метод

private CountDealPoints ( ) : void
Результат void
        private void CountDealPoints()
        {
            int northSouthExtraPoints = 0;
            int eastWestExtraPoints = 0;

            _isCapot = ( _northSouthPoints == 0 || _eastWestPoints == 0 );

            if( _currentAnnouncement.Type == AnnouncementTypeEnum.NoTrumps )
            {
                _northSouthPoints *= 2;
                _eastWestPoints *= 2;
            }

            #region Add combination points

            Player equalHolder = FindBiggestEqualCombinationHolder();
            Player sequentialHolder = FindBiggestSequentialCombinationHolder();

            if( equalHolder != null )
            {
                PlayerPosition posEq = equalHolder.Position;
                if( posEq == PlayerPosition.East || posEq == PlayerPosition.West )
                {
                    eastWestExtraPoints += GetCombinationPoints( equalHolder, _mapEqualCombinationToPlayer );
                }
                else
                {
                    northSouthExtraPoints += GetCombinationPoints( equalHolder, _mapEqualCombinationToPlayer );
                }
            }

            if( sequentialHolder != null )
            {
                PlayerPosition posSeq = sequentialHolder.Position;
                if( posSeq == PlayerPosition.East || posSeq == PlayerPosition.West )
                {
                    eastWestExtraPoints += GetCombinationPoints( sequentialHolder, _mapSequentialCombinationToPlayer );
                }
                else
                {
                    northSouthExtraPoints += GetCombinationPoints( sequentialHolder, _mapSequentialCombinationToPlayer );
                }
            }

            foreach( DictionaryEntry de in _mapBelotCombinationToPlayer )
            {
                PlayerPosition pos = ( de.Value as Player ).Position;
                if( pos == PlayerPosition.North || pos == PlayerPosition.South )
                {
                    northSouthExtraPoints += (de.Key as BelotCombination).Points;
                }
                else
                {
                    eastWestExtraPoints += (de.Key as BelotCombination).Points;
                }
            }

            #endregion

            _rawNorthSouthPoints = _northSouthPoints + northSouthExtraPoints;
            _rawEastWestPoints = _eastWestPoints + eastWestExtraPoints;

            PlayerPosition posBid = _bidWinner.Position;
            if( (_northSouthPoints + northSouthExtraPoints) > (_eastWestPoints + eastWestExtraPoints) )
            {
                if( _isCapot )
                {
                    northSouthExtraPoints += 90;
                }

                if( ( !_game.CapotRemovesDouble || !_isCapot ) && ( _currentAnnouncement.IsDoubled || _currentAnnouncement.IsReDoubled ) )
                {
                    AddDoublingPoints( ref _northSouthPoints, ref _eastWestPoints, northSouthExtraPoints, eastWestExtraPoints );
                }
                else
                {
                    if( posBid == PlayerPosition.East || posBid == PlayerPosition.West )
                    {
                        // bad game for east-west. All points go to north-south
                        _northSouthPoints += _eastWestPoints + northSouthExtraPoints + eastWestExtraPoints;
                        _eastWestPoints = 0;
                    }
                    else
                    {
                        //normal game
                        _northSouthPoints += northSouthExtraPoints;
                        _eastWestPoints += eastWestExtraPoints;
                    }
                }
            }
            else if( (_northSouthPoints + northSouthExtraPoints) < (_eastWestPoints + eastWestExtraPoints) )
            {
                if( _isCapot )
                {
                    eastWestExtraPoints += 90;
                }

                if( ( !_game.CapotRemovesDouble || !_isCapot ) && ( _currentAnnouncement.IsDoubled || _currentAnnouncement.IsReDoubled ) )
                {
                    AddDoublingPoints( ref _eastWestPoints, ref _northSouthPoints, eastWestExtraPoints, northSouthExtraPoints );
                }
                else
                {
                    if( posBid == PlayerPosition.North || posBid == PlayerPosition.South )
                    {
                        // bad game for north-south. All points go to east-west
                        _eastWestPoints += _northSouthPoints + northSouthExtraPoints + eastWestExtraPoints;
                        _northSouthPoints = 0;
                    }
                    else
                    {
                        //normal game
                        _northSouthPoints += northSouthExtraPoints;
                        _eastWestPoints += eastWestExtraPoints;
                    }
                }
            }
            else
            {
                //Hanging game
                if( posBid == PlayerPosition.North || posBid == PlayerPosition.South )
                {
                    _northSouthPoints = 0;
                    _hangingPoints = RoundPoints( _eastWestPoints );
                }
                else
                {
                    _eastWestPoints = 0;
                    _hangingPoints = RoundPoints( _northSouthPoints );
                }
            }
        }