示例#1
0
        public void DisplayTable(Table table, CardAtributte atr, Player activePlayer)
        {
            ClearScreen();
            int    cardWidth  = 30;
            int    tableWidth = cardWidth * Math.Max(table.ActiveCards.Count, table.CardsAfterDraw.Count);
            string tableView  = "---------- TABLE ----------";

            tableView = CenteredString(tableView, tableWidth);
            string playerTurn = string.Format("--------{0} Turn-----------", activePlayer.Name);

            playerTurn = CenteredString(playerTurn, tableWidth);
            string selectedAtr = "SELECTED ATRTRIBUTE: " + atr.ToString().ToUpper();

            selectedAtr = CenteredString(selectedAtr, tableWidth);
            string winningPlayer;

            if (table.WinningPlayer != null)
            {
                winningPlayer = string.Format("-------{0} wins---------", table.WinningPlayer.Name);
            }
            else
            {
                winningPlayer = "-------It`s a draw-----------";
            }


            winningPlayer = CenteredString(winningPlayer, tableWidth);

            string[] activCardsView     = CardsView(table.ActiveCards, cardWidth);
            string[] cardsAfterDrawView = CardsView(table.CardsAfterDraw, cardWidth);

            //printing to console
            View.DisplayLine(tableView);
            View.DisplayLine(playerTurn);
            View.DisplayLine(selectedAtr);
            View.DisplayLine(winningPlayer + "\n");
            if (table.ActiveCards.Count > 0)
            {
                foreach (string e in activCardsView)
                {
                    View.DisplayLine(CenteredString(e, tableWidth));
                }
            }

            View.DisplayLine();
            if (table.CardsAfterDraw.Count > 0)
            {
                View.DisplayLine(CenteredString("CARDS FROM DRAW:\n", tableWidth));
            }

            if (table.CardsAfterDraw.Count > 0)
            {
                foreach (string e in cardsAfterDrawView)
                {
                    View.DisplayLine(CenteredString(e, tableWidth));
                }
            }
            View.WaitForString();
        }
示例#2
0
        // private int GetChoiceFromActivePlayer()
        // {
        //     GameView.DisplayMessage("Select which attribiute You want to play:");
        //     return _activePlayer.GetChoice();
        // }

        void HandleRound()
        {
            _gameView.DisplayPlayer(_activePlayer);

            AssignTopCardsToPlayers();

            _gameView.DisplayCard(_table.ActiveCards[0], _activePlayer);

            int           playerChoice = _activePlayer.GetChoice();
            CardAtributte attribute    = (CardAtributte)playerChoice;

            //roundGame
            CardsComparer Comparator = new CardsComparer(attribute);

            _table.Comparator = Comparator;
            Player roundWinner = _table.GetRoundWinner();

            _gameView.DisplayTable(_table, attribute, _activePlayer);

            //substract top cards from hand player
            foreach (Player player in _players)
            {
                player.Cards.Dequeue();
            }

            //add cards to winner if is
            if (roundWinner != null)
            {
                foreach (Card elem in _table.GetRoundTrophy())
                {
                    roundWinner.Cards.Enqueue(elem);
                }
                _table.ActiveCards.Clear();
                _table.CardsAfterDraw.Clear();
            }
            //if nobody won round game them cards are adding to cardsAfterDraw
            else
            {
                _table.MoveActivCardsToAfterDraw();
            }

            //check that one player has all cards
            IsOver();
            if (_isActive == false)
            {
                _gameView.DisplayEndGame(GetWinnerGame());
            }
            _table.WhoseCards.Clear();
        }
示例#3
0
 public CardsComparer(CardAtributte feature)
 {
     Feature = feature;
 }