Beispiel #1
0
        /// <summary>
        /// Recalcuate the score of the saved dice
        /// </summary>
        private void RecalculateSavedDice()
        {
            // Reset the dice groups
            DiceItems.Where(d => d.State == DiceState.Saved).ToList().ForEach(d => d.Group = null);

            // Reset the scores
            CurrentRound.SaveScore -= _prevSave;
            CurrentRound.RiskScore -= _prevRisk;
            _prevRisk = _prevSave = 0;

            // Declare temporary variables
            DiceGroup dg    = null;
            int       count = 1;

            // While groups of dice exist, continue to group them
            while ((dg = GetDiceCheckGroup(DiceItems.Where(d => d.State == DiceState.Saved && d.Group == null))) != null)
            {
                // Apply the grouping and add the appropriate scores
                dg.Apply(count++);
                if (dg.IsScoreSaved)
                {
                    _prevSave += dg.Score;
                }
                else
                {
                    _prevRisk += dg.Score;
                }
            }

            // Reset the scores
            CurrentRound.SaveScore += _prevSave;
            CurrentRound.RiskScore += _prevRisk;
            Update();
        }
Beispiel #2
0
        public int CompareTo(object obj)
        {
            DiceGroup dg = obj as DiceGroup;

            if (dg == null)
            {
                return(1);
            }
            int compare = Group.CompareTo(dg.Group);

            return((compare == 0) ? GroupNumber.CompareTo(dg.GroupNumber) : compare);
        }
Beispiel #3
0
        public static DiceGroup CheckOfAKind(this IEnumerable <Dice> dice)
        {
            DiceGroup dg = CheckOfAKind(dice, 6, DiceGroups.SixOfAKind);

            if (dg.IsValid)
            {
                return(dg);
            }
            dg = CheckOfAKind(dice, 5, DiceGroups.FiveOfAKind);
            if (dg.IsValid)
            {
                return(dg);
            }
            dg = CheckOfAKind(dice, 4, DiceGroups.FourOfAKind);
            if (dg.IsValid)
            {
                return(dg);
            }
            return(CheckOfAKind(dice, 3, DiceGroups.ThreeOfAKind));
        }
Beispiel #4
0
        public static DiceGroup CheckSingleValue(this IEnumerable <Dice> dice)
        {
            DiceGroup dg = CheckAnyOfAValue(dice, 1, 1, DiceGroups.SingleAce);

            return(dg.IsValid ? dg : CheckAnyOfAValue(dice, 5, 1, DiceGroups.SingleFive));
        }