Esempio n. 1
0
        // Response to a choice.
        private void Game()
        {
            while (_playerScore < GameData.WIN_SCORE && _enemyScore < GameData.WIN_SCORE)
            {
                string key = _keysComparator.ReadKeyToString();

                if (_keysComparator.KeyIsSpacebar(key))
                {
                    _out.Clear();
                    Card card = _deck.Pop();
                    ScoreComputing(card, ref _playerScore);
                    _playerCards.Insert(_playerCards.Length, card + "\n");

                    if (_enemyScore < GameData.ENEMY_STOP_SCORE)
                    {
                        EnemyCardChoice();
                    }
                    _out.LoadView(_enemyCards, _playerCards, _enemyScore, _playerScore, _playerWins, _enemyWins, GameData.viewOnGame);
                }
                if (_keysComparator.KeyIsEscape(key))
                {
                    Environment.Exit(0);
                }
                if (_keysComparator.KeyIsEnter(key))
                {
                    _out.Clear();
                    while (_enemyScore < GameData.ENEMY_STOP_SCORE)
                    {
                        EnemyCardChoice();
                    }
                    ShowWinner();
                    GameFinishActions();
                }
            }
        }