protected override void Score(PlacesToScore place, int value)
        {
            switch (place)
            {
            case PlacesToScore.Ones:
                NumOnes = value;
                break;

            case PlacesToScore.Twos:
                NumTwos = value;
                break;

            case PlacesToScore.Threes:
                NumThrees = value;
                break;

            case PlacesToScore.Fours:
                NumFours = value;
                break;

            case PlacesToScore.Fives:
                NumFives = value;
                break;

            case PlacesToScore.Sixes:
                NumSixes = value;
                break;

            default:
                break;
            }
        }
        private Side convertToSideFromPlace(PlacesToScore place)
        {
            switch (place)
            {
            case PlacesToScore.Ones:
                return(Side.One);

            case PlacesToScore.Twos:
                return(Side.Two);

            case PlacesToScore.Threes:
                return(Side.Three);

            case PlacesToScore.Fours:
                return(Side.Four);

            case PlacesToScore.Fives:
                return(Side.Five);

            case PlacesToScore.Sixes:
                return(Side.Six);

            default:
                return(Side.None);
            }
        }
Ejemplo n.º 3
0
        public int getValueOf(int valueToCheck, PlacesToScore place)
        {
            if (isYahtzee(valueToCheck))
            {
                //switch(place)
                //{
                //    case PlacesToScore.SmallStraight:
                //        break;
                //    case PlacesToScore.LargeStraight:
                //        break;
                //    case { }
                //}
                return(valueToCheck - 100);
            }
            else if (valueToCheck == -1)
            {
                return(0);
            }
            return(valueToCheck);


            throw new NotImplementedException();
        }
Ejemplo n.º 4
0
        protected override void Score(PlacesToScore place, int value)
        {
            switch (place)
            {
            case PlacesToScore.ThreeOfAKind:
                ValueThreeOfAKind = value;
                break;

            case PlacesToScore.FourOfAKind:
                ValueFourOfAKind = value;
                break;

            case PlacesToScore.Chance:
                ValueChance = value;
                break;

            case PlacesToScore.FullHouse:
                HasFullHouse = value;
                break;

            case PlacesToScore.SmallStraight:
                HasSmallStraight = value;
                break;

            case PlacesToScore.LargeStraight:
                HasLargeStraight = value;
                break;

            case PlacesToScore.Yahtzee:
                HasYahtzee = value;
                break;

            default:
                break;
            }
        }
 protected abstract void Score(PlacesToScore place, int value);
Ejemplo n.º 6
0
        public static bool Score(PlacesToScore place, Die[] dice)
        {
            bool flag = false;
            Side yahtzeeSide;
            bool isYahtzee = Scoring.isYahtzee(dice, out yahtzeeSide);

            if (isYahtzee)
            {
                if (place == PlacesToScore.Yahtzee)
                {
                    lwSb.HasYahtzee = 1;
                }
                else
                {
                    if (lwSb.HasYahtzee == -1)
                    {
                        return(flag);
                    }
                }
            }


            switch (place)
            {
                #region Ones
            case PlacesToScore.Ones:

                if (isYahtzee)
                {
                    if (yahtzeeSide != Side.One)
                    {
                        return(flag);
                    }
                    lwSb.NumBonusYahtzees++;
                    upSb.NumOnes = -25;
                    flag         = true;
                    break;
                }


                int ones = Scoring.getNumOfSide(dice, Side.One);
                upSb.NumOnes = ones;
                flag         = true;
                break;

                #endregion
                #region Twos
            case PlacesToScore.Twos:

                if (isYahtzee)
                {
                    if (yahtzeeSide != Side.Two)
                    {
                        return(flag);
                    }
                    lwSb.NumBonusYahtzees++;
                    upSb.NumTwos = -25;
                    flag         = true;
                    break;
                }

                int twos = Scoring.getNumOfSide(dice, Side.Two);
                upSb.NumTwos = twos;
                flag         = true;
                break;

                #endregion
                #region Threes
            case PlacesToScore.Threes:

                if (isYahtzee)
                {
                    if (yahtzeeSide != Side.Three)
                    {
                        return(flag);
                    }
                    lwSb.NumBonusYahtzees++;
                    upSb.NumThrees = -25;
                    flag           = true;
                    break;
                }

                int threes = Scoring.getNumOfSide(dice, Side.Three);
                upSb.NumThrees = threes;
                flag           = true;
                break;

                #endregion
                #region Fours
            case PlacesToScore.Fours:

                if (isYahtzee)
                {
                    if (yahtzeeSide != Side.Four)
                    {
                        return(flag);
                    }
                    lwSb.NumBonusYahtzees++;
                    upSb.NumFours = -25;
                    flag          = true;
                    break;
                }

                int fours = Scoring.getNumOfSide(dice, Side.Four);
                upSb.NumFours = fours;
                flag          = true;
                break;

                #endregion
                #region Fives
            case PlacesToScore.Fives:

                if (isYahtzee)
                {
                    if (yahtzeeSide != Side.Five)
                    {
                        return(flag);
                    }
                    lwSb.NumBonusYahtzees++;
                    upSb.NumFives = -25;
                    flag          = true;
                    break;
                }

                int fives = Scoring.getNumOfSide(dice, Side.Five);
                upSb.NumFives = fives;
                flag          = true;
                break;

                #endregion
                #region Sixes
            case PlacesToScore.Sixes:

                if (isYahtzee)
                {
                    if (yahtzeeSide != Side.Six)
                    {
                        return(flag);
                    }
                    lwSb.NumBonusYahtzees++;
                    upSb.NumSixes = -25;
                    flag          = true;
                    break;
                }

                int sixes = Scoring.getNumOfSide(dice, Side.Six);
                upSb.NumSixes = sixes;
                flag          = true;
                break;

                #endregion
                #region Three Of A kind
            case PlacesToScore.ThreeOfAKind:
                if (isYahtzee)
                {
                    lwSb.NumBonusYahtzees++;
                    //lwSb.ValueThreeOfAKind = -25;
                    lwSb.ValueThreeOfAKind = Scoring.getTotalDiceValue(dice) + 100;
                    flag = true;
                    break;
                }
                Side side;
                bool hasThreeOfAKind = Scoring.hasXOfAKind(dice, 3, out side);
                if (hasThreeOfAKind)
                {
                    lwSb.ValueThreeOfAKind = Scoring.getTotalDiceValue(dice);
                }
                else
                {
                    lwSb.ValueThreeOfAKind = 0;
                }
                flag = true;

                break;

                #endregion
                #region Four Of A kind
            case PlacesToScore.FourOfAKind:
                if (isYahtzee)
                {
                    lwSb.NumBonusYahtzees++;
                    //lwSb.ValueFourOfAKind = -25;
                    lwSb.ValueFourOfAKind = Scoring.getTotalDiceValue(dice) + 100;
                    flag = true;
                    break;
                }

                bool hasFourOfAKind = Scoring.hasXOfAKind(dice, 4, out side);
                if (hasFourOfAKind)
                {
                    lwSb.ValueFourOfAKind = Scoring.getTotalDiceValue(dice);
                }
                else
                {
                    lwSb.ValueFourOfAKind = 0;
                }
                flag = true;

                break;

                #endregion
                #region FullHouse
            case PlacesToScore.FullHouse:
                if (isYahtzee)
                {
                    lwSb.NumBonusYahtzees++;
                    lwSb.HasFullHouse = -25;
                    flag = true;
                    break;
                }

                if (Scoring.isFullHouse(dice))
                {
                    lwSb.HasFullHouse = 25;
                }
                else
                {
                    lwSb.HasFullHouse = 0;
                }
                flag = true;
                break;

                #endregion
                #region Small Straight
            case PlacesToScore.SmallStraight:
                if (isYahtzee)
                {
                    lwSb.NumBonusYahtzees++;
                    lwSb.HasSmallStraight = -25;
                    flag = true;
                    break;
                }

                if (Scoring.isXStraight(dice, 4))
                {
                    lwSb.HasSmallStraight = 30;
                }
                else
                {
                    lwSb.HasSmallStraight = 0;
                }
                flag = true;


                break;

                #endregion
                #region Large Straight
            case PlacesToScore.LargeStraight:
                if (isYahtzee)
                {
                    lwSb.NumBonusYahtzees++;
                    lwSb.HasLargeStraight = -25;
                    flag = true;
                    break;
                }

                if (Scoring.isXStraight(dice, 5))
                {
                    lwSb.HasLargeStraight = 40;
                }
                else
                {
                    lwSb.HasLargeStraight = 0;
                }
                flag = true;
                break;

                #endregion
                #region Large Straight
            case PlacesToScore.Chance:
                if (isYahtzee)
                {
                    //lwSb.ValueChance = -25;
                    lwSb.NumBonusYahtzees++;
                    lwSb.ValueChance = Scoring.getTotalDiceValue(dice) + 100;
                    flag             = true;
                    break;
                }

                lwSb.ValueChance = Scoring.getTotalDiceValue(dice);
                flag             = true;
                break;

                #endregion
                #region Yahtzee
            case PlacesToScore.Yahtzee:
                hasYahtzee = true;
                flag       = true;
                break;
                #endregion
            }

            return(flag);
        }