当前位置: 首页>>代码示例>>C#>>正文


C# Player.AddCard方法代码示例

本文整理汇总了C#中Player.AddCard方法的典型用法代码示例。如果您正苦于以下问题:C# Player.AddCard方法的具体用法?C# Player.AddCard怎么用?C# Player.AddCard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player.AddCard方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCardTotal

 public void TestCardTotal()
 {
     Player hand = new Player();
     hand.AddCard(new Card(Rank.SEVEN, Suit.SPADE));
     hand.AddCard(new Card(Rank.JACK, Suit.SPADE));
     Assert.IsTrue(hand.CardTotal == 17);
 }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:7,代码来源:TestCard.cs

示例2: TestCardTotalWithHighAce

 public void TestCardTotalWithHighAce()
 {
     Player hand = new Player();
     hand.AddCard(new Card(Rank.ACE, Suit.SPADE));
     hand.AddCard(new Card(Rank.JACK, Suit.SPADE));
     Assert.IsTrue(hand.CardTotal == 21);
 }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:7,代码来源:TestCard.cs

示例3: TestBust

        public void TestBust()
        {
            Player player = new Player();
            Dealer dealer = new Dealer();
            Deck deck = new Deck();
            player.AddCard(new Card(Rank.NINE, Suit.DIAMOND));
            player.AddCard(new Card(Rank.TEN, Suit.SPADE));
            player.AddCard(new Card(Rank.FIVE, Suit.SPADE));

            BlackJackGame game = new BlackJackGame(deck, player, dealer);
            game.CheckScores();

            Console.WriteLine(game.Status);
            Assert.IsTrue(game.Status == GameState.LOSE);
        }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:15,代码来源:TestCard.cs

示例4: Test5CardsUnder21Win

        public void Test5CardsUnder21Win()
        {
            Player player = new Player();
            Deck deck = new Deck();
            Dealer dealer = new Dealer();
            player.AddCard(new Card(Rank.TWO, Suit.DIAMOND));
            player.AddCard(new Card(Rank.TWO, Suit.SPADE));
            player.AddCard(new Card(Rank.ACE, Suit.SPADE));
            player.AddCard(new Card(Rank.FOUR, Suit.SPADE));
            player.AddCard(new Card(Rank.ACE, Suit.HEART));

            dealer.AddCard(new Card(Rank.TEN, Suit.HEART));
            dealer.AddCard(new Card(Rank.TEN, Suit.SPADE));

            BlackJackGame game = new BlackJackGame(deck, player, dealer);
            game.CheckScores();
            Assert.IsTrue(game.Status == GameState.WIN);
        }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:18,代码来源:TestCard.cs

示例5: TestBetLose

        public void TestBetLose()
        {
            Player player = new Player();
            Deck deck = new Deck();
            Dealer dealer = new Dealer();

            BlackJackGame game = new BlackJackGame(deck, player, dealer);

            player.AddCard(new Card(Rank.TEN, Suit.DIAMOND));
            player.AddCard(new Card(Rank.FOUR, Suit.SPADE));

            dealer.AddCard(new Card(Rank.TEN, Suit.HEART));
            dealer.AddCard(new Card(Rank.EIGHT, Suit.SPADE));

            game.Decision = true;
            game.CheckScores();
            game.RestartGame ();

            Assert.IsTrue(game.Player.Money == 80);
        }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:20,代码来源:TestBetting.cs

示例6: TestDoubleDown

        public void TestDoubleDown()
        {
            Player player = new Player();
            Deck deck = new Deck();
            Dealer dealer = new Dealer();

            BlackJackGame game = new BlackJackGame(deck, player, dealer);

            player.AddCard(new Card(Rank.SIX, Suit.DIAMOND));
            player.AddCard(new Card(Rank.FIVE, Suit.SPADE));
            game.Status = GameState.PLAYING;
            game.DoubleDown();

            Console.WriteLine(player.Bet);
            Console.WriteLine(player.Cards.Count);
            Console.WriteLine(game.Decision);

            Assert.IsTrue(player.Bet == 20);
            Assert.IsTrue(player.Cards.Count == 3);
            Assert.IsTrue(game.Decision);
        }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:21,代码来源:TestBetting.cs

示例7: TestWin21

        public void TestWin21()
        {
            Player player = new Player();
            Deck deck = new Deck();
            Dealer dealer = new Dealer();

            BlackJackGame game = new BlackJackGame(deck, player, dealer);

            dealer.AddCard(new Card(Rank.TEN, Suit.HEART));
            dealer.AddCard(new Card(Rank.EIGHT, Suit.SPADE));

            player.AddCard(new Card(Rank.ACE, Suit.DIAMOND));
            player.AddCard(new Card(Rank.JACK, Suit.SPADE));

            game.CheckScores();
            game.RestartGame();
            Assert.AreEqual(105, game.Player.Money);
        }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:18,代码来源:TestBetting.cs

示例8: TestWin

        public void TestWin()
        {
            Player player = new Player();
            Dealer dealer = new Dealer();
            Deck deck = new Deck();
            player.AddCard(new Card(Rank.TEN, Suit.DIAMOND));
            player.AddCard(new Card(Rank.TEN, Suit.SPADE));

            dealer.AddCard(new Card(Rank.TEN, Suit.CLUB));
            dealer.AddCard(new Card(Rank.NINE, Suit.SPADE));

            BlackJackGame game = new BlackJackGame(deck, player, dealer);
            game.Decision = true;
            game.CheckScores();

            Assert.IsTrue(game.Status == GameState.WIN);
        }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:17,代码来源:TestCard.cs

示例9: TestPlayerTotal

 public void TestPlayerTotal()
 {
     Deck deck = new Deck();
     Player hand = new Player();
     Assert.IsTrue(hand.Cards.Count == 0);
     hand.AddCard(deck.Draw());
     Assert.IsTrue(hand.Cards.Count == 1);
 }
开发者ID:Calneideck,项目名称:Blackjack,代码行数:8,代码来源:TestCard.cs

示例10: showCards

	IEnumerator showCards(List<CardData> cards, System.Action action, Player p) {
		if (cards != null && cards.Count > 0) {
			CardData card = cards[0];
			cards.RemoveAt(0);
			yield return new WaitForSeconds(0.1f);
			_BattleUnitPositionManager.ShowSpoils(card);
			yield return new WaitForSeconds(1f);
			_BattleUnitPositionManager.ShowSpoils(card);
			p.AddCard(card);
			ModalPanel.Instance().ShowOK("Spoils", "You found a " + card.Name + " card", () => {
				_BattleUnitPositionManager.HideSpoils();
				StartCoroutine(showCards(cards, action, p));
			});
		} else {
			action();
		}
	}
开发者ID:EpicPants90,项目名称:ELB,代码行数:17,代码来源:BattleManager.cs

示例11: TestPlayerClass

        private static void TestPlayerClass(Random rand)
        {
            Console.WriteLine("# Test Player class");
            Card card = new Card(CardSuit.Acorns, CardRank.r8);
            Console.WriteLine(card);

            Player player = new Player("Teszt Elek");

            // without indexer
            player.SetCard(0, card);
            player.SetCard(1, Card.GetRandomCard(rand));
            player.SetCard(2, new Card(CardSuit.Bells, CardRank.r10));

            // with indexer
            player[0] = card;
            player[1] = Card.GetRandomCard(rand);
            player[2] = new Card(CardSuit.Bells, CardRank.r10);

            // for game
            player.AddCard(card);
            player.AddCard(Card.GetRandomCard(rand));
            player.AddCard(CardSuit.Bells, CardRank.r10);

            Console.WriteLine(player);
        }
开发者ID:davidbedok,项目名称:oeprog1,代码行数:25,代码来源:Program.cs

示例12: GetHandTotalTest

        public void GetHandTotalTest()
        {
            Player p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, 9));
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            Assert.AreEqual(21, p.GetHandTotal());
            bool pure = true;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, 5));
            p.AddCard(new BlackJackCard(Suite.Clubs, 7));
            p.AddCard(new BlackJackCard(Suite.Clubs, 9));
            Assert.AreEqual(21, p.GetHandTotal());
            pure = true;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 6));
            Assert.AreEqual(17, p.GetHandTotal());
            pure = true;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 7));
            Assert.AreEqual(18, p.GetHandTotal());
            pure = true;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 8));
            Assert.AreEqual(19, p.GetHandTotal());
            pure = true;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 9));
            Assert.AreEqual(20, p.GetHandTotal());
            pure = true;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            Assert.AreEqual(21, p.GetHandTotal());
            pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsTrue(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 11));
            Assert.AreEqual(21, p.GetHandTotal());
            pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsTrue(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.King));
            Assert.AreEqual(21, p.GetHandTotal());
            pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsTrue(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Queen));
            Assert.AreEqual(21, p.GetHandTotal());
            pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsTrue(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Jack));
            Assert.AreEqual(21, p.GetHandTotal());
            pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsTrue(pure);

            p = new Player(1, 2, null);
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 11));
            Assert.AreEqual(12, p.GetHandTotal());
            pure = true;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);
//.........这里部分代码省略.........
开发者ID:raljoach,项目名称:Games,代码行数:101,代码来源:blackjacktest.cs

示例13: HasSplitTest

        public void HasSplitTest()
        {
            var p = new Player(0, 500, null);
            p.AddCard(new BlackJackCard(Suite.Hearts, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            Assert.IsFalse(p.HasSplit());

            p = new Player(0, 500, null);
            p.AddCard(new BlackJackCard(Suite.Hearts, 10));
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            Assert.IsTrue(p.HasSplit());
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            Assert.IsFalse(p.HasSplit());
        }
开发者ID:raljoach,项目名称:Games,代码行数:14,代码来源:blackjacktest.cs

示例14: HasBlackJackTest

        public void HasBlackJackTest()
        {
            //BlackJack scenario
            var p = new Player(0, 500, null);
            p.AddCard(new BlackJackCard(Suite.Hearts, Card.Ace));
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            bool pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsTrue(pure);

            p = new Player(0, 500, null);
            p.AddCard(new BlackJackCard(Suite.Hearts, 9));
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            pure = false;
            Assert.IsFalse(p.HasBlackJack(out pure));
            p.AddCard(new BlackJackCard(Suite.Clubs, 2));
            pure = false;
            Assert.IsTrue(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            //Non-BlackJack scenario
            p = new Player(0, 500, null);
            p.AddCard(new BlackJackCard(Suite.Hearts, 10));
            p.AddCard(new BlackJackCard(Suite.Clubs, 10));
            pure = false;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);
            p.AddCard(new BlackJackCard(Suite.Clubs, 2));
            pure = false;
            Assert.IsFalse(p.HasBlackJack(out pure));
            Assert.IsFalse(pure);

            //Split scenario

            //DoubleDown scenario
        }
开发者ID:raljoach,项目名称:Games,代码行数:36,代码来源:blackjacktest.cs


注:本文中的Player.AddCard方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。