コード例 #1
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 public void DiscardCard(Hand hand, Card card)
 {
     discardPile = Crazy_Eight_Game.DiscardCard(discardPile, card);
     if (card.GetFaceValue() == FaceValue.Eight)
     {
         //set top card suit if player
         if (playerTurn)
         {
             //display form
             Suit resultSuit = Suit.Clubs; //default value
             using (ChooseSuitForm ChooseSuit = new ChooseSuitForm()){
                 var DialogResult = ChooseSuit.ShowDialog();
                 if (DialogResult == DialogResult.OK)
                 {
                     resultSuit = ChooseSuit.ReturnSuit;
                 }
                 //get new top card based on suit chosen
             }
             topCard = new Card(resultSuit, FaceValue.Eight);
         }
     }
     else
     {
         topCard = discardPile.GetLastCardInPile();
     }
     hand.RemoveCard(card);
     UpdateHandImages(hand, playerTurn);
     UpdateTopCardImage();
     //End Turn
     NextTurn();
 }
コード例 #2
0
 public Crazy_Eight()
 {
     Crazy_Eight_Game.SetUpGame();
     InitializeComponent();
     sortButton.Enabled     = false;
     instructionLabel.Text  = "Click Deal to start the game.";
     leftPictureBox.Enabled = false;
     UpdatePictureBoxImage(leftPictureBox);
 }
コード例 #3
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 //Check DrawPile for reset requirement
 public void CheckDrawPile()
 {
     if (drawPile.GetCount() == 0)
     {
         drawPile    = Crazy_Eight_Game.ResetDrawPile(discardPile);
         discardPile = Crazy_Eight_Game.SetDiscardPile(drawPile);
         UpdateTopCardImage();
     }
 }
コード例 #4
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 public void DrawCard(Hand hand)
 {
     //draw a card from the draw pile and add it to the hand
     hand.AddCard(Crazy_Eight_Game.DrawCard(drawPile));
     //Check draw pile after draw
     CheckDrawPile();
     //update hand images
     UpdateHandImages(hand, playerTurn);
     //End Turn
     NextTurn();
 }
コード例 #5
0
 private void TryToPlayCard(Card clickedCard)
 {
     // This MessageBox is for debugging purposes only.
     //MessageBox.Show(clickedCard.ToString(false, true), "Clicked");
     UpdatePictureBoxImageRight(rightPictureBox, Crazy_Eight_Game.Check(clickedCard));
     if (clickedCard.GetFaceValue() == FaceValue.Eight)
     {
         Form Crazy_Eight = new WhatSuit();
         Crazy_Eight.Show();
     }
     DisplayGuiHand(Crazy_Eight_Game.GetHand(0), bottomTableLayoutPanel, 0);
 }
コード例 #6
0
 private void dealButton_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 8; i++)
     {
         Crazy_Eight_Game.DealOneCardTo(1);
         Crazy_Eight_Game.DealOneCardTo(0);
     }
     DisplayGuiHand(Crazy_Eight_Game.GetHand(1), topTableLayoutPanel, 1);
     DisplayGuiHand(Crazy_Eight_Game.GetHand(0), bottomTableLayoutPanel, 0);
     UpdatePictureBoxImageRight(rightPictureBox, Crazy_Eight_Game.DealOneCardToMiddle());
     leftPictureBox.Enabled = true;
     dealButton.Enabled     = false;
     sortButton.Enabled     = true;
     instructionLabel.Text  = "Your turn. Click on one your cards to play.";
 }
コード例 #7
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
        }//end CrazyEightsForm

        //Setup Game - On 'Deal btn'
        public void SetupGame()
        {
            //Create a deck, shuffle and use as drawPile
            drawPile = Crazy_Eight_Game.SetDrawPile();
            //deal the cards from the draw pile
            DealCards();
            //Start the discard pile using card from draw pile
            discardPile = Crazy_Eight_Game.SetDiscardPile(drawPile);
            //Get showing discard pile card value
            topCard = discardPile.GetLastCardInPile();
            //start player turn
            PlayerTurn();
            //update hand images for both player and computer
            UpdateHandImages(playerHand, true);
            UpdateHandImages(computerHand, false);
            UpdateTopCardImage();
        }
コード例 #8
0
ファイル: WhatSuit.cs プロジェクト: I3un/CAB201
 private void button1_Click(object sender, EventArgs e)
 {
     if (radioButton1.Checked)
     {
         Crazy_Eight_Game.GetHand(2).GetCard(0).GetSuit();
     }
     else if (radioButton2.Checked)
     {
         //Suit.Diamonds;
     }
     else if (radioButton3.Checked)
     {
         //Suit.Hearts;
     }
     else if (radioButton4.Checked)
     {
         //Suit.Spades;
     }
     this.Close();
 }
コード例 #9
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 //Start player turn (before player input)
 public void PlayerTurn()
 {
     //Update Computer Hand
     //UpdateHandImages(computerHand, false);
     //check game state (returns false if no longer running)
     if (CheckGameState())
     {
         //retrieve playable cards from hand
         playerPlayableCards = Crazy_Eight_Game.CheckPlayable(playerHand, topCard);
         //if playable card is present, deny draw. If not, allow draw and prompt the user to draw.
         if (playerPlayableCards.Count() != 0)
         {
             allowDraw = false;
             output    = "Your turn. \nSelect a card to discard. \n(You have at least one)";
             UpdateInstructions();
         }
         else
         {
             //Check pass status
             CheckPass();
             if (playerPass)
             {
                 output = "Your hand is full, you cannot draw anymore cards. \nPassing your turn...";
                 UpdateInstructions();
                 NextTurn();
             }
             else
             {
                 //permit draw card
                 output = "You have no cards to discard. \nDraw a card";
                 UpdateInstructions();
                 allowDraw = true;
             }
         }
     }
     else
     {
         //end game
         EndGame();
     }
 }
コード例 #10
0
ファイル: CrazyEightsForm.cs プロジェクト: miksma/CAB201
 //Computer turn
 public void ComputerTurn()
 {
     //Update Player Hand
     //UpdateHandImages(playerHand, true);
     //check game state (returns false if no longer running)
     if (CheckGameState())
     {
         //retrieve playable cards from hand
         computerPlayableCards = Crazy_Eight_Game.CheckPlayable(computerHand, topCard);
         //if playable card is present, discard a card. If not, draw a card if possible.
         if (computerPlayableCards.Count() != 0)
         {
             //get card based on computer rules of play and discard it
             Card playCard = Crazy_Eight_Game.ComputerDecision(computerPlayableCards, topCard);
             DiscardCard(computerHand, playCard);
         }
         else
         {
             //check pass status
             CheckPass();
             if (computerPass)
             {
                 //computer pass, trigger next turn
                 NextTurn();
             }
             else
             {
                 //permit draw card
                 DrawCard(computerHand);
             }
         }
     }
     else
     {
         //end game
         EndGame();
     }
 }
コード例 #11
0
 private void leftPictureBox_Click(object sender, EventArgs e)
 {
     Crazy_Eight_Game.Add();
     DisplayGuiHand(Crazy_Eight_Game.GetHand(0), bottomTableLayoutPanel, 0);
 }
コード例 #12
0
 private void sortButton_Click(object sender, EventArgs e)
 {
     Crazy_Eight_Game.Sort();
     DisplayGuiHand(Crazy_Eight_Game.GetHand(0), bottomTableLayoutPanel, 0);
 }