Ejemplo n.º 1
0
        //Attacking phase for human players
        public virtual void AttackingPhase(GameRiver gameRiver, Card attackingCard)
        {
            CardList gameRiverList = new CardList();


            for (int i = 0; i < gameRiver.length(); i++)
            {
                gameRiverList.Add(gameRiver.GetCard(i));
            }



            switch (gameRiver.length())
            {
            case 0:


                gameRiver.AddCardToRiver(attackingCard);
                getHand().RemoveCardFromHand(attackingCard);

                break;

            case 2:
                if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank)
                {
                    gameRiver.AddCardToRiver(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);

                    break;
                }
                break;

            case 4:
                if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank | attackingCard.getCardRank() == gameRiverList[2].rank | attackingCard.getCardRank() == gameRiverList[3].rank)
                {
                    gameRiver.AddCardToRiver(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);
                    break;
                }
                break;

            case 6:
                if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank | attackingCard.getCardRank() == gameRiverList[2].rank | attackingCard.getCardRank() == gameRiverList[3].rank | attackingCard.getCardRank() == gameRiverList[4].rank | attackingCard.getCardRank() == gameRiverList[5].rank)
                {
                    gameRiver.AddCardToRiver(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);
                    break;
                }
                break;

            case 8:
                if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank | attackingCard.getCardRank() == gameRiverList[2].rank | attackingCard.getCardRank() == gameRiverList[3].rank | attackingCard.getCardRank() == gameRiverList[4].rank | attackingCard.getCardRank() == gameRiverList[5].rank)
                {
                    gameRiver.AddCardToRiver(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);
                    break;
                }
                break;
            }
        }
Ejemplo n.º 2
0
        } // end of CardSuitsEnum()

        //Beginning of GameDeck()
        static void GameDeck()
        {
            GameDeck myDeck = new GameDeck();

            myDeck.Shuffle(52);

            //showdeck
            Console.WriteLine(myDeck.ToString(myDeck));

            //player one draws a single card from deck
            Card card1;

            card1 = myDeck.DrawCard();
            Console.WriteLine(card1.ToString(1));

            //showdeck
            Console.WriteLine(myDeck.ToString(myDeck));

            //creates two player objects
            PlayerHand playerOneHand = new PlayerHand();
            PlayerHand playerTwoHand = new PlayerHand();

            //player one adds drawn card to hand
            playerOneHand.AddCardToHand(card1);
            Console.WriteLine(playerOneHand.ToString(playerOneHand, 1));


            //player two draws 6 cards
            CardList cardsDrawn1;

            cardsDrawn1 = myDeck.DrawCards(6);
            Console.WriteLine(cardsDrawn1.ToString(cardsDrawn1, 2));

            //playertwo adds cards to hand
            playerTwoHand.AddCardsToHand(cardsDrawn1);
            Console.WriteLine(playerTwoHand.ToString(playerTwoHand, 2));


            //playertwo chooses two cards from hand
            Card choosenCardFromHand1;

            choosenCardFromHand1 = playerTwoHand.ChooseCardFromHand(2);
            Card choosenCardFromHand3;

            choosenCardFromHand3 = playerTwoHand.ChooseCardFromHand(0);
            Console.WriteLine(playerTwoHand.ToString(playerTwoHand, 2));

            //player one draws cards from deck
            CardList cardsDrawn2;

            cardsDrawn2 = myDeck.DrawCards(5);
            Console.WriteLine(cardsDrawn2.ToString(cardsDrawn2, 1));
            playerOneHand.AddCardsToHand(cardsDrawn2);
            Console.WriteLine(playerOneHand.ToString(playerOneHand, 1));

            //playerone chooses two cards from hand
            Card choosenCardFromHand2;

            choosenCardFromHand2 = playerOneHand.ChooseCardFromHand(1);
            Card choosenCardFromHand4;

            choosenCardFromHand4 = playerOneHand.ChooseCardFromHand(2);
            Console.WriteLine(playerOneHand.ToString(playerOneHand, 1));

            //choosen card from playertwo put in gameriver1 list
            GameRiver gameRiver1 = new GameRiver();

            //player two choosen cards added to river
            gameRiver1.AddCardToRiver(choosenCardFromHand1);
            gameRiver1.AddCardToRiver(choosenCardFromHand3);

            //player one choosen cards added to river
            gameRiver1.AddCardToRiver(choosenCardFromHand2);
            gameRiver1.AddCardToRiver(choosenCardFromHand4);
            Console.WriteLine(gameRiver1.ToString(gameRiver1));


            //Console.WriteLine(gameRiver1.cardRiverComparison());



            Console.ReadKey();



            //GameDeck Functionality
            GameDeck deck1 = new GameDeck();
            GameDeck deck2 = (GameDeck)deck1.Clone();

            Console.WriteLine("\nThe first card in the original deck is: {0}",
                              deck1.GetCard(0));
            Console.WriteLine("The first card in the cloned deck is: {0}",
                              deck2.GetCard(0));
            deck1.Shuffle(52);
            Console.WriteLine("Original deck shuffled.");
            Console.WriteLine("The first card in the original deck is: {0}",
                              deck1.GetCard(0));
            Console.WriteLine("The first card in the cloned deck is: {0}",
                              deck2.GetCard(0));

            Console.ReadKey();
        } // end of GameDeck()
Ejemplo n.º 3
0
        //ComputerAttackingPhase method, guides the ai through attacking phase
        public void AttackingPhase(GameRiver gameRiver)
        {
            Card attackingCard = new Card();

            CardList gameRiverList = new CardList();

            bool sucessfullattack = false;

            for (int i = 0; i < gameRiver.length(); i++)
            {
                gameRiverList.Add(gameRiver.GetCard(i));
            }


            switch (gameRiver.length())
            {
            case 0:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    attackingCard = getHand().ChooseCardFromHand(i);

                    gameRiver.AddCardToRiver(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);
                    sucessfullattack = true;
                    break;
                }
                break;

            case 2:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    attackingCard = getHand().ChooseCardFromHand(i);

                    if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank)
                    {
                        gameRiver.AddCardToRiver(attackingCard);
                        getHand().RemoveCardFromHand(attackingCard);
                        sucessfullattack = true;
                        break;
                    }
                }
                break;

            case 4:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    attackingCard = getHand().ChooseCardFromHand(i);

                    if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank | attackingCard.getCardRank() == gameRiverList[2].rank | attackingCard.getCardRank() == gameRiverList[3].rank)
                    {
                        gameRiver.AddCardToRiver(attackingCard);
                        getHand().RemoveCardFromHand(attackingCard);
                        sucessfullattack = true;
                        break;
                    }
                }
                break;

            case 6:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    attackingCard = getHand().ChooseCardFromHand(i);

                    if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank | attackingCard.getCardRank() == gameRiverList[2].rank | attackingCard.getCardRank() == gameRiverList[3].rank | attackingCard.getCardRank() == gameRiverList[4].rank | attackingCard.getCardRank() == gameRiverList[5].rank)
                    {
                        gameRiver.AddCardToRiver(attackingCard);
                        getHand().RemoveCardFromHand(attackingCard);
                        sucessfullattack = true;
                        break;
                    }
                }
                break;

            case 8:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    attackingCard = getHand().ChooseCardFromHand(i);

                    if (attackingCard.getCardRank() == gameRiverList[0].rank | attackingCard.getCardRank() == gameRiverList[1].rank | attackingCard.getCardRank() == gameRiverList[2].rank | attackingCard.getCardRank() == gameRiverList[3].rank | attackingCard.getCardRank() == gameRiverList[4].rank | attackingCard.getCardRank() == gameRiverList[5].rank)
                    {
                        gameRiver.AddCardToRiver(attackingCard);
                        getHand().RemoveCardFromHand(attackingCard);
                        sucessfullattack = true;
                        break;
                    }
                }
                break;
            }


            if (sucessfullattack == false && gameRiver.length() == 0 | gameRiver.length() == 2 | gameRiver.length() == 4 | gameRiver.length() == 6 | gameRiver.length() == 8)
            {
                setIsDefending(true);
            }
        }
Ejemplo n.º 4
0
        //ComputerDefendingPhase method, guides the ai through Defending phase
        public void DefendingPhase(GameRiver gameRiver, Card trumpCard)
        {
            Card     defendingCard     = new Card();
            CardList gameRiverList     = new CardList();
            bool     sucessfulldefense = false;

            //int computerInput = 0;

            for (int i = 0; i < gameRiver.length(); i++)
            {
                gameRiverList.Add(gameRiver.GetCard(i));
            }

            switch (gameRiver.length())
            {
            case 1:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    defendingCard = getHand().ChooseCardFromHand(i);

                    if (defendingCard.getCardSuit() == gameRiverList[0].suit & defendingCard > gameRiverList[0] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[0])
                    {
                        gameRiver.AddCardToRiver(defendingCard);
                        getHand().RemoveCardFromHand(defendingCard);
                        sucessfulldefense = true;
                        break;
                    }
                }
                break;

            case 3:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    defendingCard = getHand().ChooseCardFromHand(i);

                    if (defendingCard.getCardSuit() == gameRiverList[2].suit & defendingCard > gameRiverList[2] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[2])
                    {
                        gameRiver.AddCardToRiver(defendingCard);
                        getHand().RemoveCardFromHand(defendingCard);
                        sucessfulldefense = true;
                        break;
                    }
                }
                break;


            case 5:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    defendingCard = getHand().ChooseCardFromHand(i);

                    if (defendingCard.getCardSuit() == gameRiverList[4].suit & defendingCard > gameRiverList[4] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[4])
                    {
                        gameRiver.AddCardToRiver(defendingCard);
                        getHand().RemoveCardFromHand(defendingCard);
                        sucessfulldefense = true;
                        break;
                    }
                }
                break;

            case 7:
                //AI chooses a card
                for (int i = 0; i < getHand().length(); i++)
                {
                    defendingCard = getHand().ChooseCardFromHand(i);

                    if (defendingCard.getCardSuit() == gameRiverList[6].suit & defendingCard > gameRiverList[6] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[6])
                    {
                        gameRiver.AddCardToRiver(defendingCard);
                        getHand().RemoveCardFromHand(defendingCard);
                        sucessfulldefense = true;
                        break;
                    }
                }
                break;
            }

            if (sucessfulldefense == false && gameRiver.length() == 1 | gameRiver.length() == 3 | gameRiver.length() == 5 | gameRiver.length() == 7)
            {
                setIsDefending(false);
            }
        }
Ejemplo n.º 5
0
        //Defending phase for human players
        public virtual void DefendingPhase(GameRiver gameRiver, Card trumpCard, Card defendingCard)
        {
            //Card defendingCard = new Card();
            CardList gameRiverList     = new CardList();
            bool     sucessfulldefense = false;


            //gameRiver.AddCardToRiver(defendingCard);
            //getHand().RemoveCardFromHand(defendingCard);
            //sucessfulldefense = true;



            for (int i = 0; i < gameRiver.length(); i++)
            {
                gameRiverList.Add(gameRiver.GetCard(i));
            }



            switch (gameRiver.length())
            {
            case 1:


                if (defendingCard.getCardSuit() == gameRiverList[0].suit & defendingCard > gameRiverList[0] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[0])
                {
                    gameRiver.AddCardToRiver(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;

            case 3:


                if (defendingCard.getCardSuit() == gameRiverList[2].suit & defendingCard > gameRiverList[2] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[2])
                {
                    gameRiver.AddCardToRiver(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;


            case 5:


                if (defendingCard.getCardSuit() == gameRiverList[4].suit & defendingCard > gameRiverList[4] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[4])
                {
                    gameRiver.AddCardToRiver(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;

            case 7:


                if (defendingCard.getCardSuit() == gameRiverList[6].suit & defendingCard > gameRiverList[6] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameRiverList[6])
                {
                    gameRiver.AddCardToRiver(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;
            }



            //if (sucessfulldefense == false)
            //{
            //    setIsDefending(false);
            //}
        }