Beispiel #1
0
        public override void specialEffect()
        {
            int           counter           = 0;
            List <string> cardsPlayerCanBuy = new List <string>();

            //CardOwner.GameBoard.clearConsoleButKeepPlayerTurn(CardOwner);
            Console.WriteLine("Gain a card costing up to 4:");
            List <string> cardsNames = CardOwner.GameBoard.globalCardsPiles.getCardsNames();

            foreach (string cardName in cardsNames)
            {
                if (CardOwner.GameBoard.globalCardsPiles.getCardsPile(cardName).CardTemplate.Cost <= 4 &&
                    CardOwner.GameBoard.globalCardsPiles.getCardsPile(cardName).size() > 0)
                {
                    cardsPlayerCanBuy.Add(cardName);
                    Console.Write("[" + (counter++) + "] - ");
                }
                Console.Write("\t");
                CardsUtilities.printCardName(CardOwner.GameBoard.globalCardsPiles.getCardsPile(cardName));
            }

            int playerChoice = Convert.ToInt32(Console.ReadLine());

            CardOwner.CardsPiles.moveCardFromGlobalPilesToPlayerDiscardPile(cardsPlayerCanBuy[playerChoice]);
        }
Beispiel #2
0
        public override void specialEffect()
        {
            List <string> cardsNames        = CardOwner.GameBoard.globalCardsPiles.getCardsNames();
            int           emptyPilesCounter = 0;

            foreach (string cardName in cardsNames)
            {
                if (CardOwner.GameBoard.globalCardsPiles.getCardsPile(cardName).isEmpty())
                {
                    emptyPilesCounter++;
                }
            }

            for (int i = 0; i < emptyPilesCounter; i++)
            {
                CardOwner.GameBoard.clearConsoleButKeepPlayerTurn(CardOwner);
                Console.WriteLine("Discard " + (emptyPilesCounter - i) + " card.");
                Console.WriteLine("Choose what card you want to discard:");
                int counter = 0;
                foreach (Card card in CardOwner.CardsPiles.Hand)
                {
                    Console.Write("[" + (counter++) + "] - ");
                    CardsUtilities.printCardName(card);
                }
                int playerChoice = Convert.ToInt32(Console.ReadLine());
                CardOwner.CardsPiles.moveCardFromHandToDiscardPile(playerChoice);
            }
        }
Beispiel #3
0
        public void start()
        {
            _globalCardsPiles = new GlobalCardsPiles(this);
            for (int i = 0; i < num_of_players; i++)
            {
                Console.WriteLine("Enter the name of player #" + (i + 1));
                players[i] = new Player(Console.ReadLine(), this);
            }

            int currentPlayerIndex = 0;

            while (!isGameOver())
            {
                Player currentPlayer = Players[currentPlayerIndex];
                currentPlayer.initPlayerNewRound();
                clearConsoleButKeepPlayerTurn(currentPlayer);

                //Action phase
                while (currentPlayer.ActionsCounter > 0 && currentPlayer.CardsPiles.countActionCardsInHand() > 0)
                {
                    Console.WriteLine("Actions: " + currentPlayer.ActionsCounter + " / Buys: " +
                                      currentPlayer.BuysCounter + " / Total cards in hand: " + currentPlayer.CardsPiles.Hand.Count);
                    Console.WriteLine("Choose what action card you want to play:");
                    Console.Write("[0] - ");
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("End action phase");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    int counter = 1;
                    foreach (Card card in currentPlayer.CardsPiles.Hand)
                    {
                        if (card is ActionCard)
                        {
                            Console.Write("[" + (counter++) + "] - ");
                        }
                        CardsUtilities.printCardName(card);
                    }
                    int playerChoice = Convert.ToInt32(Console.ReadLine());
                    if (playerChoice == 0)
                    {
                        break;
                    }

                    currentPlayer.CardsPiles.playNthActionCard(playerChoice);
                    clearConsoleButKeepPlayerTurn(currentPlayer);
                }
                clearConsoleButKeepPlayerTurn(currentPlayer);
                //Buy phase
                while (currentPlayer.BuysCounter > 0)
                {
                    Console.WriteLine("Actions: " + currentPlayer.ActionsCounter + " / Buys: " +
                                      currentPlayer.BuysCounter + " / Total cards in hand: " + currentPlayer.CardsPiles.Hand.Count +
                                      " / Money: " + currentPlayer.MoneyCounter);
                    Console.WriteLine("Choose what treasure card you want to play from hand or card you want to buy:");
                    Console.Write("[0] - ");
                    Console.ForegroundColor = ConsoleColor.Magenta;
                    Console.WriteLine("End buy phase");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.Write("[1] - ");
                    Console.ForegroundColor = ConsoleColor.DarkYellow;
                    Console.WriteLine("Autoplay all treasures");
                    Console.ForegroundColor = ConsoleColor.Gray;
                    Console.WriteLine("---------------------");
                    Console.WriteLine("Your hand:");
                    int counter = 2;
                    foreach (Card card in currentPlayer.CardsPiles.Hand)
                    {
                        if (card is TreasureCard)
                        {
                            Console.Write("[" + (counter++) + "] - ");
                        }
                        CardsUtilities.printCardName(card);
                    }
                    Console.WriteLine("---------------------");
                    Console.WriteLine("Game board piles:");
                    List <string> cardsNames = globalCardsPiles.getCardsNames();
                    foreach (string cardName in cardsNames)
                    {
                        if (globalCardsPiles.getCardsPile(cardName).CardTemplate.Cost <= currentPlayer.MoneyCounter &&
                            globalCardsPiles.getCardsPile(cardName).size() > 0)
                        {
                            Console.Write("[" + (counter++) + "] - ");
                        }
                        Console.Write("\t");
                        CardsUtilities.printCardName(globalCardsPiles.getCardsPile(cardName));
                    }

                    int playerChoice = Convert.ToInt32(Console.ReadLine());
                    if (playerChoice == 0)
                    {
                        break;
                    }
                    if (playerChoice == 1)
                    {
                        currentPlayer.CardsPiles.playAllTreasureCards();
                        clearConsoleButKeepPlayerTurn(currentPlayer);
                        continue;
                    }
                    playerChoice--;
                    if (playerChoice <= currentPlayer.CardsPiles.countTreasureCardsInHand())
                    {
                        currentPlayer.CardsPiles.playNthTreasureCard(playerChoice);
                    }
                    else
                    {
                        playerChoice -= currentPlayer.CardsPiles.countTreasureCardsInHand();
                        currentPlayer.CardsPiles.buyNthCardPlayerCanBuy(playerChoice);
                    }
                    clearConsoleButKeepPlayerTurn(currentPlayer);
                }

                currentPlayer.finalizePlayerRound();
                currentPlayerIndex = (currentPlayerIndex + 1) % num_of_players;
                clearConsoleButKeepPlayerTurn(currentPlayer);
            }

            andTheWinnerIs();
        }