コード例 #1
0
        public void BlackJackGame_WhenDealerAndPlayerHas19Points_ShouldSetPlayerAsLooser()
        {
            // Arrange
            BlackJackGame theGame  = new BlackJackGame(1);
            var           expected = PlayerGameStatus.Looser;

            // Act
            theGame.Dealer.AddCardToHand(new Card("Kung", 10));
            theGame.Dealer.AddCardToHand(new Card("9", 9));

            theGame.Players[0].AddCardToHand(new Card("Kung", 10));
            theGame.Players[0].AddCardToHand(new Card("9", 9));

            theGame.FinishGame();

            // Assert
            Assert.AreEqual(expected, theGame.Players[0].GameStatus);
        }
コード例 #2
0
        public void BlackJackGame_WhenPlayerHasBJAndDealerHas21_ShouldSetPlayerGameStatusToWinner()
        {
            // Arrange
            BlackJackGame theGame  = new BlackJackGame(1);
            var           expected = PlayerGameStatus.Winner;

            // Act
            theGame.Dealer.AddCardToHand(new Card("Kung", 10));
            theGame.Dealer.AddCardToHand(new Card("7", 7));
            theGame.Dealer.AddCardToHand(new Card("4", 4));

            theGame.Players[0].AddCardToHand(new Card("Kung", 10));
            theGame.Players[0].AddCardToHand(new Card("Äss", 11));

            theGame.FinishGame();

            // Assert
            Assert.AreEqual(expected, theGame.Players[0].GameStatus);
        }
コード例 #3
0
        /// <summary>
        /// 结束要牌.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnStand_Click(object sender, EventArgs e)
        {
            // 玩家结束.
            game.PlayerStand(player);


            // 电脑玩家结束处理.
            computerPlayer.DoAutoHitOrStand(game);

            // 显示计算机玩家的所有牌
            ShowComputerAllCards();


            this.btnHit.Visible   = false;
            this.btnStand.Visible = false;
            this.btnStart.Visible = true;

            // 完成游戏.
            game.FinishGame();

            // 显示游戏结果.
            ShowGameResult();
        }