本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
//.........这里部分代码省略.........
示例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());
}
示例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
}