-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDealerEntity.cs
More file actions
60 lines (50 loc) · 1.56 KB
/
DealerEntity.cs
File metadata and controls
60 lines (50 loc) · 1.56 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
using System;
using System.Collections.Generic;
namespace BlackjackSandbox
{
/// <summary>
/// An entity that will play like a dealer would
/// </summary>
public class DealerEntity : Entity
{
bool m_hitSoftSeventeen;
/// <summary>
/// Creates a new entity that will play as a dealer would
/// </summary>
/// <param name="hitSoftSeventeen">Should this entity hit on soft 17?</param>
public DealerEntity(bool hitSoftSeventeen) : base(0, "Dealer")
{
m_hitSoftSeventeen = hitSoftSeventeen;
}
/// <summary>
/// Dealers dont bet!
/// </summary>
public override int GetBet(int count)
{
throw new NotSupportedException();
}
public override TurnAction TakeTurn(List<Card> hand, Card dealerHoleCard)
{
bool soft;
int value = HandHelper.GetHandValue(hand.AsReadOnly(), out soft);
//If we're less than 17, always hit
if (value < 17)
{
return TurnAction.Hit;
}
//If we're at 17, soft and should hit on soft 17s...
else if (value == 17 && soft && m_hitSoftSeventeen)
{
return TurnAction.Hit;
}
return TurnAction.Stick;
}
/// <summary>
/// Dealers don't double down!
/// </summary>
public override int GetDoubleDownBet(List<Card> hand, int count)
{
throw new NotSupportedException();
}
}
}