public bool IsChickenHandChanged(int handId)
        {
            DBHand hand = _hands.Find(x => x.HandId == handId);
            bool   returnValue;

            if (hand.IsChickenHand)
            {
                returnValue = false;
            }
            else
            {
                if (!hand.HandScore.Equals(string.Empty) &&
                    !hand.PlayerWinnerId.Equals(string.Empty) &&
                    !hand.PlayerLooserId.Equals(string.Empty))
                {
                    returnValue = true;
                }
                else
                {
                    _form.PlayKoSound();
                    _form.ShowMessageChickenHandNeedWinnerLooserAndScore();
                    returnValue = false;
                }
            }
            _db.UpdateHandIsChickenHand(_hands.Find(x => x.HandId == handId), returnValue);
            return(returnValue);
        }
Ejemplo n.º 2
0
        public void UpdateHandPlayerNorthPenalty(DBHand hand, string newPlayerNorthPenaltyValue)
        {
            DBHand dbHand = _db.Hands.ToList().Find(x => x.HandTournamentId == hand.HandTournamentId &&
                                                    x.HandTableId == hand.HandTableId && x.HandRoundId == hand.HandRoundId && x.HandId == hand.HandId);

            dbHand.PlayerNorthPenalty = newPlayerNorthPenaltyValue;
            _db.SaveChanges();
        }
Ejemplo n.º 3
0
        public void UpdateHandIsChickenHand(DBHand hand, bool newIsChickenHand)
        {
            DBHand dbHand = _db.Hands.ToList().Find(x => x.HandTournamentId == hand.HandTournamentId &&
                                                    x.HandTableId == hand.HandTableId && x.HandRoundId == hand.HandRoundId && x.HandId == hand.HandId);

            dbHand.IsChickenHand = newIsChickenHand;
            _db.SaveChanges();
        }
Ejemplo n.º 4
0
        public void UpdateHandScore(DBHand hand, string newHandScore)
        {
            DBHand dbHand = _db.Hands.ToList().Find(x => x.HandTournamentId == hand.HandTournamentId &&
                                                    x.HandTableId == hand.HandTableId && x.HandRoundId == hand.HandRoundId && x.HandId == hand.HandId);

            dbHand.HandScore = newHandScore;
            _db.SaveChanges();
        }
Ejemplo n.º 5
0
        public void UpdateHandLooserId(DBHand hand, string newLooserPlayerId)
        {
            DBHand dbHand = _db.Hands.ToList().Find(x => x.HandTournamentId == hand.HandTournamentId &&
                                                    x.HandTableId == hand.HandTableId && x.HandRoundId == hand.HandRoundId && x.HandId == hand.HandId);

            dbHand.PlayerLooserId = newLooserPlayerId;
            _db.SaveChanges();
        }
        public string PlayerNorthPenalytChanged(int handId, string newValue)
        {
            DBHand hand        = _hands.Find(x => x.HandId == handId);
            string returnValue = ValidatePenalty(hand.PlayerNorthPenalty, newValue);

            _db.UpdateHandPlayerNorthPenalty(hand, returnValue);
            CalculateAndFillAllHandsScoresAndPlayersTotalsAndPoints();
            return(returnValue);
        }
Ejemplo n.º 7
0
 public DGVHand(DBHand dbHand)
     : base(dbHand.HandTournamentId, dbHand.HandRoundId,
            dbHand.HandTableId, dbHand.HandId, dbHand.PlayerWinnerId,
            dbHand.PlayerLooserId, dbHand.HandScore, dbHand.IsChickenHand,
            dbHand.PlayerEastPenalty, dbHand.PlayerSouthPenalty,
            dbHand.PlayerWestPenalty, dbHand.PlayerNorthPenalty)
 {
     PlayerEastScore  = string.Empty;
     PlayerSouthScore = string.Empty;
     PlayerWestScore  = string.Empty;
     PlayerNorthScore = string.Empty;
 }
        public string HandScoreChanged(int handId, string newValue)
        {
            DBHand hand        = _hands.Find(x => x.HandId == handId);
            string returnValue = string.Empty;
            int    validValue;

            if (newValue == null || newValue.Equals(string.Empty))
            {
                if (hand.IsChickenHand)
                {
                    UncheckChickenHandAndNotifyUser(hand);
                }
                returnValue = string.Empty;
            }
            else if (int.TryParse(newValue, out validValue))
            {
                if (validValue >= MCR_MIN_POINTS)
                {
                    returnValue = validValue.ToString();
                }
                else if (validValue == 0 &&
                         hand.PlayerWinnerId.Equals(string.Empty) &&
                         hand.PlayerLooserId.Equals(string.Empty))
                {
                    if (hand.IsChickenHand)
                    {
                        UncheckChickenHandAndNotifyUser(hand);
                    }
                    returnValue = validValue.ToString();
                }
                else
                {
                    _form.PlayKoSound();
                    returnValue = hand.HandScore;
                }
            }
            else
            {
                _form.PlayKoSound();
                returnValue = hand.HandScore;
            }
            _db.UpdateHandScore(_hands.Find(x => x.HandId == handId), returnValue);
            CalculateAndFillAllHandsScoresAndPlayersTotalsAndPoints();
            return(returnValue);
        }
        public string PlayerLooserIdChanged(int handId, string newValue)
        {
            DBHand hand        = _hands.Find(x => x.HandId == handId);
            string returnValue = string.Empty;
            int    validValue;

            if (newValue == null || newValue.Equals(string.Empty))
            {
                if (hand.IsChickenHand)
                {
                    UncheckChickenHandAndNotifyUser(hand);
                }
                returnValue = string.Empty;
            }
            else if (int.TryParse(newValue, out validValue))
            {
                if (validValue == 0)
                {
                    if (hand.IsChickenHand)
                    {
                        UncheckChickenHandAndNotifyUser(hand);
                    }
                    returnValue = string.Empty;
                }
                else if (validValue > 0 && IsACurrentTablePlayerId(validValue) &&
                         !hand.PlayerLooserId.Equals(validValue.ToString()))
                {
                    returnValue = validValue.ToString();
                }
                else
                {
                    _form.PlayKoSound();
                    returnValue = hand.PlayerLooserId;
                }
            }
            else
            {
                _form.PlayKoSound();
                returnValue = hand.PlayerLooserId;
            }
            _db.UpdateHandLooserId(hand, returnValue);
            CalculateAndFillAllHandsScoresAndPlayersTotalsAndPoints();
            return(returnValue);
        }
 private void UncheckChickenHandAndNotifyUser(DBHand hand)
 {
     _form.PlayKoSound();
     _form.UncheckChickenHand(hand.HandId);
 }