private void CalculateTsumo(DGVHand dgvHand)
        {
            string winnerPoints = ((int.Parse(dgvHand.HandScore) + MCR_MIN_POINTS) * NUM_LOOSER_PLAYERS).ToString();
            string looserPoints = (-(int.Parse(dgvHand.HandScore) + MCR_MIN_POINTS)).ToString();

            if (dgvHand.PlayerWinnerId.Equals(_table.PlayerEastId))
            {
                dgvHand.PlayerEastScore  = winnerPoints;
                dgvHand.PlayerSouthScore = looserPoints;
                dgvHand.PlayerWestScore  = looserPoints;
                dgvHand.PlayerNorthScore = looserPoints;
            }
            else if (dgvHand.PlayerWinnerId.Equals(_table.PlayerSouthId))
            {
                dgvHand.PlayerEastScore  = looserPoints;
                dgvHand.PlayerSouthScore = winnerPoints;
                dgvHand.PlayerWestScore  = looserPoints;
                dgvHand.PlayerNorthScore = looserPoints;
            }
            else if (dgvHand.PlayerWinnerId.Equals(_table.PlayerWestId))
            {
                dgvHand.PlayerEastScore  = looserPoints;
                dgvHand.PlayerSouthScore = looserPoints;
                dgvHand.PlayerWestScore  = winnerPoints;
                dgvHand.PlayerNorthScore = looserPoints;
            }
            else
            {
                dgvHand.PlayerEastScore  = looserPoints;
                dgvHand.PlayerSouthScore = looserPoints;
                dgvHand.PlayerWestScore  = looserPoints;
                dgvHand.PlayerNorthScore = winnerPoints;
            }
        }
 private void CalculateWashout(DGVHand dgvHand)
 {
     dgvHand.PlayerEastScore  = "0";
     dgvHand.PlayerSouthScore = "0";
     dgvHand.PlayerWestScore  = "0";
     dgvHand.PlayerNorthScore = "0";
 }
Exemple #3
0
 public void FillHandPlayersScoresCells(DGVHand dgvHand)
 {
     SetEastPlayerHandScoreCell(dgvHand.HandId, dgvHand.PlayerEastScore);
     SetSouthPlayerHandScoreCell(dgvHand.HandId, dgvHand.PlayerSouthScore);
     SetWestPlayerHandScoreCell(dgvHand.HandId, dgvHand.PlayerWestScore);
     SetNorthPlayerHandScoreCell(dgvHand.HandId, dgvHand.PlayerNorthScore);
 }
        private void CalculateRon(DGVHand dgvHand)
        {
            string winnerPoints      = (int.Parse(dgvHand.HandScore) + (8 * NUM_LOOSER_PLAYERS)).ToString();
            string looserPoints      = (-(int.Parse(dgvHand.HandScore) + 8)).ToString();
            string restPlayersPoints = "-8";

            //EAST
            if (_table.PlayerEastId.Equals(dgvHand.PlayerWinnerId))
            {
                dgvHand.PlayerEastScore = winnerPoints;
            }
            else if (_table.PlayerEastId.Equals(dgvHand.PlayerLooserId))
            {
                dgvHand.PlayerEastScore = looserPoints;
            }
            else
            {
                dgvHand.PlayerEastScore = restPlayersPoints;
            }
            //SOUTH
            if (_table.PlayerSouthId.Equals(dgvHand.PlayerWinnerId))
            {
                dgvHand.PlayerSouthScore = winnerPoints;
            }
            else if (_table.PlayerSouthId.Equals(dgvHand.PlayerLooserId))
            {
                dgvHand.PlayerSouthScore = looserPoints;
            }
            else
            {
                dgvHand.PlayerSouthScore = restPlayersPoints;
            }
            //WEST
            if (_table.PlayerWestId.Equals(dgvHand.PlayerWinnerId))
            {
                dgvHand.PlayerWestScore = winnerPoints;
            }
            else if (_table.PlayerWestId.Equals(dgvHand.PlayerLooserId))
            {
                dgvHand.PlayerWestScore = looserPoints;
            }
            else
            {
                dgvHand.PlayerWestScore = restPlayersPoints;
            }
            //NORTH
            if (_table.PlayerNorthId.Equals(dgvHand.PlayerWinnerId))
            {
                dgvHand.PlayerNorthScore = winnerPoints;
            }
            else if (_table.PlayerNorthId.Equals(dgvHand.PlayerLooserId))
            {
                dgvHand.PlayerNorthScore = looserPoints;
            }
            else
            {
                dgvHand.PlayerNorthScore = restPlayersPoints;
            }
        }
        private void CalculateAndFillAllHandsScoresAndPlayersTotalsAndPoints()
        {
            if (!IsFilledAnyHand())
            {
                _form.EnableTotalScoresTextBoxes();
                FillAllPlayersTotalScores();
                FillAllPlayersPoints();
                return;
            }
            _form.DisableTotalScoresTextBoxes();

            if (_dgvHands != null)
            {
                bool finishCalculation = false;
                foreach (DBHand hand in _hands)
                {
                    DGVHand dgvHand = _dgvHands.Find(x => x.HandId == hand.HandId);
                    dgvHand = new DGVHand(hand);
                    if (finishCalculation)
                    {
                        _form.FillHandPlayersScoresCells(dgvHand);
                    }
                    else
                    {
                        switch (hand.GetHandType())
                        {
                        case HandType.WASHOUT:
                            CalculateWashout(dgvHand);
                            CalculatePenalties(dgvHand);
                            _form.FillHandPlayersScoresCells(dgvHand);
                            break;

                        case HandType.TSUMO:
                            CalculateTsumo(dgvHand);
                            CalculatePenalties(dgvHand);
                            _form.FillHandPlayersScoresCells(dgvHand);
                            break;

                        case HandType.RON:
                            CalculateRon(dgvHand);
                            CalculatePenalties(dgvHand);
                            _form.FillHandPlayersScoresCells(dgvHand);
                            break;

                        case HandType.NONE:
                        default:
                            finishCalculation = true;
                            _form.FillHandPlayersScoresCells(new DGVHand(hand));
                            break;
                        }
                    }
                }
                CalculateAndSaveAndFillAllPlayersTotalScoresAndPoints();
            }
        }
 private void CalculatePenalties(DGVHand dgvHand)
 {
     if (!dgvHand.PlayerEastPenalty.Equals(string.Empty))
     {
         dgvHand.PlayerEastScore = (int.Parse(dgvHand.PlayerEastScore) + int.Parse(dgvHand.PlayerEastPenalty)).ToString();
     }
     if (!dgvHand.PlayerSouthPenalty.Equals(string.Empty))
     {
         dgvHand.PlayerSouthScore = (int.Parse(dgvHand.PlayerSouthScore) + int.Parse(dgvHand.PlayerSouthPenalty)).ToString();
     }
     if (!dgvHand.PlayerWestPenalty.Equals(string.Empty))
     {
         dgvHand.PlayerWestScore = (int.Parse(dgvHand.PlayerWestScore) + int.Parse(dgvHand.PlayerWestPenalty)).ToString();
     }
     if (!dgvHand.PlayerNorthPenalty.Equals(string.Empty))
     {
         dgvHand.PlayerNorthScore = (int.Parse(dgvHand.PlayerNorthScore) + int.Parse(dgvHand.PlayerNorthPenalty)).ToString();
     }
 }