Exemplo n.º 1
0
 //displays discard cards
 public void DisplayDiscardCards()
 {
     if (discardDisplayList.Count() > 0)
     {
         CardImageControl startingCardControl = new CardImageControl();
         flp_discard_pile.Controls.Add(startingCardControl);
     }
 }
Exemplo n.º 2
0
        //displays trump card
        public void DisplayTrumpCards()
        {
            flp_trump_card.Controls.Clear();
            trumpCardDisplayList.Clear();

            for (int i = 0; i < 1; i++)
            {
                trumpCardDisplayList.Add(myDeck.getTrumpCard());
            }
            foreach (Card card in trumpCardDisplayList)
            {
                CardImageControl myCardControl = new CardImageControl();
                myCardControl.Card = card;
                flp_trump_card.Controls.Add(myCardControl);
            }
        }
Exemplo n.º 3
0
        //resets game
        public void ResetGame()
        {
            lbl_human_attacking.Visible    = true;
            lbl_computer_attacking.Visible = false;
            lbl_human_player.Text          = myPlayerOne.getName().ToString();
            lbl_computer_player.Text       = myPlayerTwo.getName().ToString();
            flp_deck.Controls.Clear();
            flp_computers_hand.Controls.Clear();
            flp_player_hand.Controls.Clear();
            flp_river_hand.Controls.Clear();
            flp_trump_card.Controls.Clear();
            flp_discard_pile.Controls.Clear();
            CardImageControl startingCardControl = new CardImageControl();

            flp_deck.Controls.Add(startingCardControl);
            myDeck               = new Deck(deckSize);
            myRiver              = new CenterCards();
            myHandOne            = new PlayerCard();
            myHandTwo            = new PlayerCard();
            myPlayerOne          = new Player(userName, myHandOne, true, false);
            myPlayerTwo          = new DurakAI("PlayerTwo", myHandTwo, false, true);
            DeckDisplayList      = new CardList();
            HandOneDisplayList   = new CardList();
            HandTwoDisplayList   = new CardList();
            PlayerOneDisplayList = new CardList();
            PlayerTwoDisplayList = new CardList();
            RiverDisplayList     = new CardList();
            trumpCardDisplayList = new CardList();
            discardDisplayList   = new CardList();
            myDeck.Shuffle(deckSize);

            txt_deck_cards_remaining.Text   = myDeck.getCardsRemaining().ToString();
            txt_river_cards_remaning.Text   = myRiver.getCardsRemaining().ToString();
            txt_dicard_cards_remaining.Text = discardDisplayList.Count().ToString();
            txtRoundNumber.Text             = roundNumber.ToString();

            btn_pick_up.Enabled      = false;
            btn_cease_attack.Enabled = true;

            roundNumber = 0;
            DateTime localDate = DateTime.Now;

            GameLog.Log("\nNEW GAME - " + localDate.ToString() + " " + localDate.Kind);
            GameLog.Log("\n " + userName.ToUpper() + " Win/Loss Ratio " + playerOneWins.ToString() + "/" + playerOneLosses.ToString());
            GameLog.Log("\n PlayerTwo Win/Loss Ratio " + playerTwoWins.ToString() + "/" + playerTwoLosses.ToString() + "\n");
        }
Exemplo n.º 4
0
        //displays river cards
        public void DisplayRiverCards()
        {
            //River Display Cards

            flp_river_hand.Controls.Clear();
            RiverDisplayList.Clear();

            for (int i = 0; i < myRiver.length(); i++)
            {
                RiverDisplayList.Add(myRiver.GetCard(i));
            }
            foreach (Card card in RiverDisplayList)
            {
                CardImageControl myCardControl = new CardImageControl();
                myCardControl.Card = card;
                flp_river_hand.Controls.Add(myCardControl);
            }
        }
Exemplo n.º 5
0
        //displays player one cards
        public void DisplayPlayerOneCards()
        {
            //PlayerOne Display Cards

            flp_player_hand.Controls.Clear();
            PlayerOneDisplayList.Clear();

            for (int i = 0; i < myPlayerOne.getHand().length(); i++)
            {
                PlayerOneDisplayList.Add(myPlayerOne.getHand().GetCard(i));
            }
            foreach (Card card in PlayerOneDisplayList)
            {
                CardImageControl myCardControl = new CardImageControl();
                myCardControl.Card = card;
                flp_player_hand.Controls.Add(myCardControl);

                //stores a card click event method for each card
                myCardControl.CardClicked += new EventHandler(Card_Click);
            }
        }
Exemplo n.º 6
0
        //displays player two cards
        public void DisplayPlayerTwoCards()
        {
            //PlayerTwo Display Cards

            flp_computers_hand.Controls.Clear();
            PlayerTwoDisplayList.Clear();

            for (int i = 0; i < myPlayerTwo.getHand().length(); i++)
            {
                PlayerTwoDisplayList.Add(myPlayerTwo.getHand().GetCard(i));
            }
            foreach (Card card in PlayerTwoDisplayList)
            {
                //CardImageControl myCardControl = new CardImageControl();
                //myCardControl.Card = card;
                //flpComputerHand.Controls.Add(myCardControl);

                //myCardControl.CardClicked += new EventHandler(Card_Click);

                CardImageControl startingCardControl = new CardImageControl();
                flp_computers_hand.Controls.Add(startingCardControl);
            }
        }
Exemplo n.º 7
0
        //on card click will raise event in card image control class
        //clicked card will go through player attack/defend phase method
        private void Card_Click(object sender, EventArgs e)
        {
            CardImageControl clickedCardControl = new CardImageControl();

            clickedCardControl = (CardImageControl)sender;

            //if (myPlayerTwo.getIsDefending() == false)
            //{
            //    myPlayerOne.setIsDefending(true);
            //}
            //else if (myPlayerTwo.getIsDefending() == true)
            //{
            //    myPlayerOne.setIsDefending(false);
            //}

            //checks to see if computer is defending if so human player attack phas starts and computer
            //defend phase begins
            if (myPlayerTwo.getIsDefending() == true)
            {
                myPlayerOne.Attacking(myRiver, (clickedCardControl.Card));

                myPlayerTwo.DefendingPhase(myRiver, myDeck.getTrumpCard());


                //checks to see if computer is defending if not will log round in output file
                //will reset round and have human start defending
                if (myPlayerTwo.getIsDefending() == false)
                {
                    roundNumber += 1;

                    GameLog.LogRound(GameLog, roundNumber, myPlayerOne, myPlayerTwo, myRiver);


                    for (int i = 0; i < myRiver.length(); i++)
                    {
                        myHandTwo.CardToHand(myRiver.GetCard(i));
                    }
                    myRiver.ClearCenter();
                    lbl_computer_attacking.Visible = true;
                    lbl_human_attacking.Visible    = false;
                    try
                    {
                        myPlayerOne.RefillHand(myDeck);
                        myPlayerTwo.RefillHand(myDeck);
                    }
                    catch (Exception)
                    {
                    }

                    btn_pick_up.Enabled      = true;
                    btn_cease_attack.Enabled = false;

                    myPlayerTwo.Attacking(myRiver);
                }
            }

            //human is defending, from computer attacks
            else
            {
                myPlayerOne.DefendingPhase(myRiver, myDeck.getTrumpCard(), (clickedCardControl.Card));
                myPlayerTwo.Attacking(myRiver);

                //if human no longer defending, round over and reset, computer is now defending
                if (myPlayerTwo.getIsDefending() == true)
                {
                    roundNumber += 1;

                    GameLog.LogRound(GameLog, roundNumber, myPlayerOne, myPlayerTwo, myRiver);

                    for (int i = 0; i < myRiver.length(); i++)
                    {
                        discardDisplayList.Add(myRiver.GetCard(i));
                    }
                    myRiver.ClearCenter();
                    lbl_computer_attacking.Visible = false;
                    lbl_human_attacking.Visible    = true;
                    try
                    {
                        myPlayerOne.RefillHand(myDeck);
                        myPlayerTwo.RefillHand(myDeck);
                    }
                    catch (Exception)
                    {
                    }
                    btn_pick_up.Enabled      = false;
                    btn_cease_attack.Enabled = true;
                }
            }



            DisplayAllCardLists();

            //logs who won the game and win/loss ratios
            if (myPlayerOne.getHand().length() == 0)
            {
                playerOneWins   += 1;
                playerTwoLosses += 1;
                MessageBox.Show("GAME OVER: PLAYER ONE HAS WON");
                GameLog.Log("\n*****GAME OVER: PLAYER ONE HAS WON***** \n");
                GameLog.Log("\n " + userName.ToUpper() + " Win/Loss Ratio " + playerOneWins.ToString() + "/" + playerOneLosses.ToString());
                GameLog.Log("\n PlayerTwo Win/Loss Ratio " + playerTwoWins.ToString() + "/" + playerTwoLosses.ToString() + "\n");
                ResetGame();
            }

            if (myPlayerTwo.getHand().length() == 0)
            {
                playerTwoWins   += 1;
                playerOneLosses += 1;
                MessageBox.Show("GAME OVER: PLAYER TWO HAS WON");
                GameLog.Log("\n*****GAME OVER: PLAYER TWO HAS WON***** \n");
                GameLog.Log("\n " + userName.ToUpper() + " Win/Loss Ratio " + playerOneWins.ToString() + "/" + playerOneLosses.ToString());
                GameLog.Log("\n PlayerTwo Win/Loss Ratio " + playerTwoWins.ToString() + "/" + playerTwoLosses.ToString() + "\n");
                ResetGame();
            }
        }