Beispiel #1
0
        //Attacking phase for human players
        public virtual void Attacking(CenterCards gameCenter, Card attackingCard)
        {
            CardList gameCenterList = new CardList();


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



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


                gameCenter.CardToCenter(attackingCard);
                getHand().RemoveCardFromHand(attackingCard);

                break;

            case 2:
                if (attackingCard.getCardRank() == gameCenterList[0].rank | attackingCard.getCardRank() == gameCenterList[1].rank)
                {
                    gameCenter.CardToCenter(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);

                    break;
                }
                break;

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

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

            case 8:
                if (attackingCard.getCardRank() == gameCenterList[0].rank | attackingCard.getCardRank() == gameCenterList[1].rank | attackingCard.getCardRank() == gameCenterList[2].rank | attackingCard.getCardRank() == gameCenterList[3].rank | attackingCard.getCardRank() == gameCenterList[4].rank | attackingCard.getCardRank() == gameCenterList[5].rank)
                {
                    gameCenter.CardToCenter(attackingCard);
                    getHand().RemoveCardFromHand(attackingCard);
                    break;
                }
                break;
            }
        }
Beispiel #2
0
        //displaying center cards
        public String ToString(CenterCards gameCenter1)
        {
            String gameCenterString = "";

            gameCenterString += "\n\n\tCenterCards\n\t";
            for (int i = 0; i < gameCenter1.length(); i++)
            {
                Card tempCard = gameCenter1.GetCard(i);
                gameCenterString += tempCard.ToString();
                if (i != 51)
                {
                    gameCenterString += ", ";
                }
            }

            return(gameCenterString);
        }
Beispiel #3
0
        //Defending phase for human players
        public virtual void DefendingPhase(CenterCards gameCenter, Card trumpCard, Card defendingCard)
        {
            //Card defendingCard = new Card();
            CardList gameCenterList    = new CardList();
            bool     sucessfulldefense = false;



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



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


                if (defendingCard.getCardSuit() == gameCenterList[0].suit & defendingCard > gameCenterList[0] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[0])
                {
                    gameCenter.CardToCenter(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;

            case 3:


                if (defendingCard.getCardSuit() == gameCenterList[2].suit & defendingCard > gameCenterList[2] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[2])
                {
                    gameCenter.CardToCenter(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;


            case 5:


                if (defendingCard.getCardSuit() == gameCenterList[4].suit & defendingCard > gameCenterList[4] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[4])
                {
                    gameCenter.CardToCenter(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;

            case 7:


                if (defendingCard.getCardSuit() == gameCenterList[6].suit & defendingCard > gameCenterList[6] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[6])
                {
                    gameCenter.CardToCenter(defendingCard);
                    getHand().RemoveCardFromHand(defendingCard);
                    sucessfulldefense = true;
                    break;
                }


                break;
            }
        }
Beispiel #4
0
        //clones the center cards
        public object Clone()
        {
            CenterCards newGameCenter = new CenterCards(gameCenter.Clone() as CardList);

            return(newGameCenter);
        }
Beispiel #5
0
        //ComputerAttacking method
        public void Attacking(CenterCards gameCenter)
        {
            Card attackingCard = new Card();

            CardList gameCenterList = new CardList();

            bool sucessfullattack = false;

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


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

                    gameCenter.CardToCenter(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() == gameCenterList[0].rank | attackingCard.getCardRank() == gameCenterList[1].rank)
                    {
                        gameCenter.CardToCenter(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() == gameCenterList[0].rank | attackingCard.getCardRank() == gameCenterList[1].rank | attackingCard.getCardRank() == gameCenterList[2].rank | attackingCard.getCardRank() == gameCenterList[3].rank)
                    {
                        gameCenter.CardToCenter(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() == gameCenterList[0].rank | attackingCard.getCardRank() == gameCenterList[1].rank | attackingCard.getCardRank() == gameCenterList[2].rank | attackingCard.getCardRank() == gameCenterList[3].rank | attackingCard.getCardRank() == gameCenterList[4].rank | attackingCard.getCardRank() == gameCenterList[5].rank)
                    {
                        gameCenter.CardToCenter(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() == gameCenterList[0].rank | attackingCard.getCardRank() == gameCenterList[1].rank | attackingCard.getCardRank() == gameCenterList[2].rank | attackingCard.getCardRank() == gameCenterList[3].rank | attackingCard.getCardRank() == gameCenterList[4].rank | attackingCard.getCardRank() == gameCenterList[5].rank)
                    {
                        gameCenter.CardToCenter(attackingCard);
                        getHand().RemoveCardFromHand(attackingCard);
                        sucessfullattack = true;
                        break;
                    }
                }
                break;
            }


            if (sucessfullattack == false && gameCenter.length() == 0 | gameCenter.length() == 2 | gameCenter.length() == 4 | gameCenter.length() == 6 | gameCenter.length() == 8)
            {
                setIsDefending(true);
            }
        }
Beispiel #6
0
        //ComputerDefendingPhase method
        public void DefendingPhase(CenterCards gameCenter, Card trumpCard)
        {
            Card     defendingCard     = new Card();
            CardList gameCenterList    = new CardList();
            bool     sucessfulldefense = false;

            //int computerInput = 0;

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

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

                    if (defendingCard.getCardSuit() == gameCenterList[0].suit & defendingCard > gameCenterList[0] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[0])
                    {
                        gameCenter.CardToCenter(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() == gameCenterList[2].suit & defendingCard > gameCenterList[2] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[2])
                    {
                        gameCenter.CardToCenter(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() == gameCenterList[4].suit & defendingCard > gameCenterList[4] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[4])
                    {
                        gameCenter.CardToCenter(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() == gameCenterList[6].suit & defendingCard > gameCenterList[6] | defendingCard.getCardSuit() == trumpCard.getCardSuit() & defendingCard > gameCenterList[6])
                    {
                        gameCenter.CardToCenter(defendingCard);
                        getHand().RemoveCardFromHand(defendingCard);
                        sucessfulldefense = true;
                        break;
                    }
                }
                break;
            }

            if (sucessfulldefense == false && gameCenter.length() == 1 | gameCenter.length() == 3 | gameCenter.length() == 5 | gameCenter.length() == 7)
            {
                setIsDefending(false);
            }
        }
Beispiel #7
0
 //logging stats
 public void LogRound(GameLog gameLog, int roundNumber, Player playerOne, Player playerTwo, CenterCards gameCenter)
 {
     gameLog.Log("\nROUND: " + roundNumber.ToString()
                 + "\n\t" + playerOne.getHand().ToString(playerOne.getHand(), playerOne.getName())
                 + "\n\n\t" + playerTwo.getHand().ToString(playerTwo.getHand(), playerTwo.getName())
                 + gameCenter.ToString(gameCenter));
 }