Beispiel #1
0
        public Player(string name, Label[] scoreTOTALS)
        {
            this.name = name;

            // For loop will run through all the 18 ScoreType's to set the array scores[] to a value.
            for (ScoreType combo = ScoreType.Ones; combo <= ScoreType.GrandTotal; combo++)
            {
                switch (combo)
                {
                // For the ScoreType of:
                case ScoreType.Ones:
                case ScoreType.Twos:
                case ScoreType.Threes:
                case ScoreType.Fours:
                case ScoreType.Fives:
                case ScoreType.Sixes: {
                    // Instantains the scores[] array to it corresponding label and passes to its specific score class.
                    scores[(int)combo] = new CountingCombination(combo, scoreTOTALS[(int)combo]);

                    break;
                }

                // For the ScoreType of:
                case ScoreType.ThreeOfAKind:
                case ScoreType.FourOfAKind:
                case ScoreType.Chance: {
                    scores[(int)combo] = new TotalOfDice(combo, scoreTOTALS[(int)combo]);

                    break;
                }

                // For the ScoreType of:
                case ScoreType.FullHouse:
                case ScoreType.SmallStraight:
                case ScoreType.LargeStraight:
                case ScoreType.Yahtzee: {
                    scores[(int)combo] = new FixedScore(combo, scoreTOTALS[(int)combo]);

                    break;
                }

                case ScoreType.SubTotal:
                case ScoreType.SectionATotal:
                case ScoreType.SectionBTotal:
                case ScoreType.BonusFor63Plus:
                case ScoreType.YahtzeeBonus:
                case ScoreType.GrandTotal: {
                    scores[(int)combo] = new BonusOrTotal(scoreTOTALS[(int)combo]);

                    break;
                }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Calculates the counting combination score for that specific ScoreType.
        /// </summary>
        /// <param name="score">The counting combination ScoreType.</param>
        /// <param name="dieValues">An integer array with all of the values from the die.</param>
        private void CalculateCountingCombination(ScoreType score, int[] dieValues)
        {
            //cast the specific score element as a CountingCombination
            CountingCombination combination = (CountingCombination)scores[(int)score];



            //if the roll was a yahtzee and the yahtzee combination has been done and
            //is not 0, add a yahtzee bonus to the yahtzee bonus score
            combination.CheckForYahtzee(dieValues);
            if (combination.IsYahtzee && scores[(int)ScoreType.Yahtzee].Points != 0 &&
                scores[(int)ScoreType.Yahtzee].Done)
            {
                scores[(int)ScoreType.YahtzeeBonus].Points += YAHTZEE_BONUS;
            }

            combination.CalculateScore(dieValues);
        }
Beispiel #3
0
        public Player(string name, Label[] scoreTotals)
        {
            this.name = name;
            scores    = new Score[Form1.NUM_SCORES_LOWER + Form1.NUM_SCORES_UPPER + Form1.NUM_TOTALS];

            for (int i = 0; i < scores.Length; i++)
            {
                #region Switch
                switch ((int)scoreTotals[i].Tag)
                {
                case 0:
                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                    scores[i] = new CountingCombination(scoreTotals[i]);
                    break;

                case 9:
                case 10:
                case 14:
                    scores[i] = new TotalofDice((ScoreType)scoreTotals[i].Tag, scoreTotals[i]);
                    break;

                case 11:
                case 12:
                case 13:
                case 15:
                    scores[i] = new FixedScore(scoreTotals[i]);
                    break;

                case 6:
                case 7:
                case 8:
                case 16:
                case 17:
                case 18:
                    scores[i] = new BonusOrTotal(scoreTotals[i]);
                    break;
                }
                #endregion
            }
        }
Beispiel #4
0
        /// <summary>
        /// Method for initializing the scores of a player
        /// </summary>
        /// <param name="myLabels"> Labels representing the scores </param>
        private void InitializeScoreArray(Label[] myLabels)
        {
            scores = new Score[myLabels.Length];

            foreach (ScoreType i in Enum.GetValues(typeof(ScoreType)))
            {
                switch (i)
                {
                case ScoreType.Ones:
                case ScoreType.Twos:
                case ScoreType.Threes:
                case ScoreType.Fours:
                case ScoreType.Fives:
                case ScoreType.Sixes:
                    scores[(int)i] = new CountingCombination(i, myLabels[(int)i]);
                    break;

                case ScoreType.SmallStraight:
                case ScoreType.LargeStraight:
                case ScoreType.FullHouse:
                case ScoreType.Yahtzee:
                    scores[(int)i] = new FixedScore(i, myLabels[(int)i]);
                    break;

                case ScoreType.ThreeOfAKind:
                case ScoreType.FourOfAKind:
                case ScoreType.Chance:
                    scores[(int)i] = new TotalOfDice(i, myLabels[(int)i]);
                    break;

                case ScoreType.SubTotal:
                case ScoreType.BonusFor63Plus:
                case ScoreType.SectionATotal:
                case ScoreType.SectionBTotal:
                case ScoreType.YahtzeeBonus:
                case ScoreType.GrandTotal:
                    scores[(int)i] = new BonusOrTotal(myLabels[(int)i]);
                    break;
                }
            }
        }
Beispiel #5
0
        private void instantiate()
        {
            scores = new Score[scoreTotals.Length];
            for (int i = 0; i < scores.Length; i++)
            {
                switch (scoretype[i])
                {
                case ScoreType.Ones:
                case ScoreType.Twos:
                case ScoreType.Threes:
                case ScoreType.Fours:
                case ScoreType.Fives:
                case ScoreType.Sixes:
                    scores[i] = new CountingCombination(scoretype[i], scoreTotals[i]);
                    break;

                case ScoreType.SmallStraight:
                case ScoreType.LargeStraight:
                case ScoreType.FullHouse:
                case ScoreType.Yahtzee:
                    scores[i] = new FixedScore(scoretype[i], scoreTotals[i]);
                    break;

                case ScoreType.ThreeOfAKind:
                case ScoreType.FourOfAKind:
                case ScoreType.Chance:
                    scores[i] = new TotalOfDice(scoretype[i], scoreTotals[i]);
                    break;

                case ScoreType.BonusFor63Plus:
                case ScoreType.SubTotal:
                case ScoreType.SectionATotal:
                case ScoreType.YahtzeeBonus:
                case ScoreType.SectionBTotal:
                case ScoreType.GrandTotal:
                    scores[i] = new BonusOrTotal(scoreTotals[i]);
                    break;
                }
            }
        }
Beispiel #6
0
        public Player(string playerName, Label[] playerScores) {
            name = playerName;
            grandTotal = 0;
            scores = new Score[19];
            for (int i = 0; i <= (int)ScoreType.GrandTotal; i++) {
                switch ((ScoreType)i) {
                    case (ScoreType.Ones):
                    case (ScoreType.Twos):
                    case (ScoreType.Threes):
                    case (ScoreType.Fours):
                    case (ScoreType.Fives):
                    case (ScoreType.Sixes):
                        scores[i] = new CountingCombination((ScoreType)i, playerScores[i]);
                        break;

                    case (ScoreType.ThreeOfAKind):
                    case (ScoreType.FourOfAKind):
                    case (ScoreType.Chance):
                        scores[i] = new TotalOfDice((ScoreType)i, playerScores[i]);
                        break;
                    case (ScoreType.FullHouse):
                    case (ScoreType.SmallStraight):
                    case (ScoreType.LargeStraight):
                    case (ScoreType.Yahtzee):
                        scores[i] = new FixedScore((ScoreType)i, playerScores[i]);
                        break;
                    case (ScoreType.SubTotal):
                    case (ScoreType.BonusFor63Plus):
                    case (ScoreType.SectionATotal):
                    case (ScoreType.YahtzeeBonus):
                    case (ScoreType.SectionBTotal):
                    case (ScoreType.GrandTotal):
                        scores[i] = new BonusOrTotal(playerScores[i]);
                        break;
                }
            }
        }//END Player
Beispiel #7
0
        /// <summary>
        /// This constructor will assign the name to the player
        /// and the labels will represent the socre totals on the GUI
        /// </summary>
        /// <param name="playerName"></param>
        /// <param name="scoreTotal"></param>
        public Player(string playerName, Label[] scoreTotal)
        {
            name = playerName;

            //instantiate score in scores array
            for (ScoreType index = ScoreType.Ones; index <= ScoreType.GrandTotal; index++)
            {
                switch (index)
                {
                case ScoreType.Ones:
                case ScoreType.Twos:
                case ScoreType.Threes:
                case ScoreType.Fours:
                case ScoreType.Fives:
                case ScoreType.Sixes:
                    scores[(int)index] = new CountingCombination(index, scoreTotal[(int)index]);
                    break;

                case ScoreType.ThreeOfAKind:
                case ScoreType.FourOfAKind:
                case ScoreType.Chance:
                    scores[(int)index] = new TotalOfDice(index, scoreTotal[(int)index]);
                    break;

                case ScoreType.LargeStraight:
                case ScoreType.SmallStraight:
                case ScoreType.Yahtzee:
                case ScoreType.FullHouse:
                    scores[(int)index] = new FixedScore(index, scoreTotal[(int)index]);
                    break;

                default:
                    scores[(int)index] = new BonusOrTotal(scoreTotal[(int)index]);
                    break;
                }
            }
        }//end Player
Beispiel #8
0
        /// <summary>
        /// Initialises each score label with their specific ScoreType.
        /// </summary>
        /// <param name="score">The ScoreType that is to be assigned.</param>
        /// <param name="label">The Label of the ScoreType that is to be used.</param>
        private void InitialiseScoreLabels(ScoreType score, Label label)
        {
            switch (score)
            {
            case ScoreType.Ones:
                scores[(int)score] = new CountingCombination(score, label);
                break;

            case ScoreType.Twos:
                scores[(int)score] = new CountingCombination(score, label);
                break;

            case ScoreType.Threes:
                scores[(int)score] = new CountingCombination(score, label);
                break;

            case ScoreType.Fours:
                scores[(int)score] = new CountingCombination(score, label);
                break;

            case ScoreType.Fives:
                scores[(int)score] = new CountingCombination(score, label);
                break;

            case ScoreType.Sixes:
                scores[(int)score] = new CountingCombination(score, label);
                break;

            case ScoreType.SubTotal:
                scores[(int)score] = new BonusOrTotal(label);
                break;

            case ScoreType.BonusFor63Plus:
                scores[(int)score] = new BonusOrTotal(label);
                break;

            case ScoreType.SectionATotal:
                scores[(int)score] = new BonusOrTotal(label);
                break;

            case ScoreType.ThreeOfAKind:
                scores[(int)score] = new TotalOfDice(score, label);
                break;

            case ScoreType.FourOfAKind:
                scores[(int)score] = new TotalOfDice(score, label);
                break;

            case ScoreType.FullHouse:
                scores[(int)score] = new FixedScore(score, label);
                break;

            case ScoreType.SmallStraight:
                scores[(int)score] = new FixedScore(score, label);
                break;

            case ScoreType.LargeStraight:
                scores[(int)score] = new FixedScore(score, label);
                break;

            case ScoreType.Chance:
                scores[(int)score] = new TotalOfDice(score, label);
                break;

            case ScoreType.Yahtzee:
                scores[(int)score] = new FixedScore(score, label);
                break;

            case ScoreType.YahtzeeBonus:
                scores[(int)score] = new BonusOrTotal(label);
                break;

            case ScoreType.SectionBTotal:
                scores[(int)score] = new BonusOrTotal(label);
                break;

            case ScoreType.GrandTotal:
                scores[(int)score] = new BonusOrTotal(label);
                break;
            }
        }