Repository navigation
Expand file tree
/
Copy pathDealer.cs
More file actions
82 lines (73 loc) · 2.11 KB
/
Copy pathDealer.cs
File metadata and controls
82 lines (73 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
namespace Blackjack
{
class Dealer
{
private List<Card> _hiddenCards = new List<Card>();
private List<Card> _revealedCards = new List<Card>();
public void addHiddenCard(Card card)
{
this._hiddenCards.Add(card);
}
public void addCard(Card card)
{
this._revealedCards.Add(card);
}
public void revealCard()
{
this._revealedCards.Add(this._hiddenCards[0]);
this._hiddenCards.RemoveAt(0);
}
public int getHandValue()
{
int sum = 0;
foreach (Card card in _hiddenCards)
{
sum += card.Value;
}
foreach (Card card in _revealedCards)
{
sum += card.Value;
}
return sum;
}
private void determineAceValue()
{
foreach (Card card in this._hiddenCards)
{
if (card.Face == Face.Ace && this.getHandValue() > 21)
{
card.Value = 1;
}
}
foreach (Card card in this._revealedCards)
{
if (card.Face == Face.Ace && this.getHandValue() > 21)
{
card.Value = 1;
}
}
}
public void printHand()
{
Console.ForegroundColor = ConsoleColor.Yellow;
System.Console.WriteLine("Dealer hand:");
Casino.resetColors();
for (int i = 0; i < this._hiddenCards.Count; i++)
{
Console.BackgroundColor = ConsoleColor.DarkRed;
Console.ForegroundColor = ConsoleColor.White;
System.Console.WriteLine("<Hidden>");
Casino.resetColors();
}
foreach (Card card in _revealedCards)
{
card.printInfo();
}
}
public void resetHand()
{
this._hiddenCards = new List<Card>();
this._revealedCards = new List<Card>();
}
}
}