Example #1
0
 public Form1()
 {
     InitializeComponent();
     dice              = new YahtzeeDice();
     dice.DiceChanged += diceChangedHandler;
     scoreCard         = new YahtzeeScoreCard();
 }
Example #2
0
        public YahtzeeUI()
        {
            InitializeComponent();
            random = new RandomNumberGenerator();

            dice          = new YahtzeeDice(random);
            dice.Changed += new YahtzeeDice.ChangeHandler(UpdatePossibleScoreLabels);

            scoreCard = new YahtzeeScoreCard();

            dicePictureBoxes = new PictureBox[5]
            {
                die1PictureBox,
                die2PictureBox,
                die3PictureBox,
                die4PictureBox,
                die5PictureBox
            };
            dicePictures = new Bitmap[6]
            {
                Properties.Resources.die_01,
                Properties.Resources.die_02,
                Properties.Resources.die_03,
                Properties.Resources.die_04,
                Properties.Resources.die_05,
                Properties.Resources.die_06
            };
            setScoreButtons(false);
        }
Example #3
0
 private void resetRolls()
 {
     UpdateScoreCard();
     if (scoreOnesButton.Visible || scoreTwosButton.Visible || scoreThreeButton.Visible || scoreFoursButton.Visible || scoreFivesButton.Visible || scoreSixesButton.Visible ||
         scoreThreeOfAKindButton.Visible || scoreFourOfAKindButton.Visible || scoreSmallStraightButton.Visible || scoreLargeStraightButton.Visible || scoreYahtzeeButton.Visible || scoreChanceButton.Visible)
     {
         RollButton.Enabled = true;
     }
     else
     {
         RollButton.Text    = "GAME OVER!";
         RollButton.Enabled = false;
     }
     foreach (PictureBox dicePicture in dicePictureBoxes)
     {
         dicePicture.Image = null;
     }
     dice.Changed        -= UpdatePossibleScoreLabels;
     dice                 = new YahtzeeDice(random);
     dice.Changed        += new YahtzeeDice.ChangeHandler(UpdatePossibleScoreLabels);
     dieOneHolding.Text   = "";
     dieTwoHolding.Text   = "";
     dieThreeHolding.Text = "";
     dieFourHolding.Text  = "";
     dieFiveHolding.Text  = "";
     setScoreButtons(false);
 }
Example #4
0
        private void UpdatePossibleScoreLabels(YahtzeeDice dice)
        {
            if (scoreOnesButton.Visible)
            {
                onesScoreLabel.Text = dice.getPossibleScores().Ones.ToString();
            }
            if (scoreTwosButton.Visible)
            {
                twosScoreLabel.Text = dice.getPossibleScores().Twos.ToString();
            }
            if (scoreThreeButton.Visible)
            {
                threesScoreLabel.Text = dice.getPossibleScores().Threes.ToString();
            }
            if (scoreFoursButton.Visible)
            {
                foursScoreLabel.Text = dice.getPossibleScores().Fours.ToString();
            }
            if (scoreFivesButton.Visible)
            {
                fivesScoreLabel.Text = dice.getPossibleScores().Fives.ToString();
            }
            if (scoreSixesButton.Visible)
            {
                sixesScoreLabel.Text = dice.getPossibleScores().Sixes.ToString();
            }

            if (scoreThreeOfAKindButton.Visible)
            {
                threeOfAKindScoreLabel.Text = dice.getPossibleScores().ThreeOfAKind.ToString();
            }
            if (scoreFourOfAKindButton.Visible)
            {
                fourOfAKindScoreLabel.Text = dice.getPossibleScores().FourOfAKind.ToString();
            }
            if (scoreFullHouseButton.Visible)
            {
                fullHouseScoreLabel.Text = dice.getPossibleScores().FullHouse.ToString();
            }
            if (scoreSmallStraightButton.Visible)
            {
                smallStraightScoreLabel.Text = dice.getPossibleScores().SmallStraight.ToString();
            }
            if (scoreLargeStraightButton.Visible)
            {
                largeStraightScoreLabel.Text = dice.getPossibleScores().LargeStraight.ToString();
            }
            if (scoreYahtzeeButton.Visible)
            {
                yahtzeeScoreLabel.Text = dice.getPossibleScores().Yahtzee.ToString();
            }
            if (scoreChanceButton.Visible)
            {
                chanceScoreLabel.Text = dice.getPossibleScores().Chance.ToString();
            }
        }
Example #5
0
 public bool ScoreChance()
 {
     if (!HasScoredChance)
     {
         savedScores.Chance = possibleScoreboard.Chance;
         dice = new YahtzeeDice();
         possibleScoreboard = new YahtzeeScoreboard(dice.getDiceValues());
         HasScoredChance    = true;
         return(true);
     }
     return(false);
 }
Example #6
0
 public bool ScoreLargeStraight()
 {
     if (!HasScoredLargeStraight)
     {
         savedScores.LargeStraight = possibleScoreboard.LargeStraight;
         dice = new YahtzeeDice();
         possibleScoreboard     = new YahtzeeScoreboard(dice.getDiceValues());
         HasScoredLargeStraight = true;
         return(true);
     }
     return(false);
 }
Example #7
0
 public bool ScoreFourOfAKind()
 {
     if (!HasScoredFourOfAKind)
     {
         savedScores.FourOfAKind = possibleScoreboard.FourOfAKind;
         dice = new YahtzeeDice();
         possibleScoreboard   = new YahtzeeScoreboard(dice.getDiceValues());
         HasScoredFourOfAKind = true;
         return(true);
     }
     return(false);
 }
Example #8
0
 public bool ScoreSixes()
 {
     if (!HasScoredSixes)
     {
         savedScores.Sixes = possibleScoreboard.Sixes;
         dice = new YahtzeeDice();
         possibleScoreboard = new YahtzeeScoreboard(dice.getDiceValues());
         HasScoredSixes     = true;
         return(true);
     }
     return(false);
 }
Example #9
0
 public YahtzeeGame()
 {
     dice = new YahtzeeDice();
     possibleScoreboard     = new YahtzeeScoreboard(dice.getDiceValues());
     savedScores            = new YahtzeeScoreboard();
     HasScoredOnes          = false;
     HasScoredTwos          = false;
     HasScoredThrees        = false;
     HasScoredFours         = false;
     HasScoredFives         = false;
     HasScoredSixes         = false;
     HasScoredThreeOfAKind  = false;
     HasScoredFourOfAKind   = false;
     HasScoredFullHouse     = false;
     HasScoredSmallStraight = false;
     HasScoredLargeStraight = false;
     HasScoredYahtzee       = false;
     HasScoredChance        = false;
 }
Example #10
0
        private void reset()
        {
            rollButton.Enabled = true;
            dice.DiceChanged  -= diceChangedHandler;
            dice              = new YahtzeeDice();
            dice.DiceChanged += diceChangedHandler;
            holdDie1.Checked  = false;
            holdDie2.Checked  = false;
            holdDie3.Checked  = false;
            holdDie4.Checked  = false;
            holdDie5.Checked  = false;

            die1.Text = string.Empty;
            die2.Text = string.Empty;
            die3.Text = string.Empty;
            die4.Text = string.Empty;
            die5.Text = string.Empty;

            upperBonusLabel.Text = $"Upper Bonus: {scoreCard.UpperBonus()}";
        }