-
Notifications
You must be signed in to change notification settings - Fork 1
/
Player.h
79 lines (63 loc) · 2.02 KB
/
Player.h
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
#ifndef PLAYER_H_
#define PLAYER_H_
#include <vector>
#include <memory>
#include "Hand.h"
#include "Card.h"
enum Decision {
stand,
hit,
double_down,
split
};
class Player {
private:
std::string name;
double count;
int bet;
int net_gains;
protected:
void addToCount(double to_add) { count += to_add; }
public:
Player(std::string _name, int _bet) : name(_name), count(0), bet(_bet), net_gains(0) {}
std::string getName() { return name; }
double getCount() { return count; }
int getBet() { return bet; }
void setBet(int _bet) { bet = _bet; }
int getNetGains() { return net_gains; }
void reset() { count = 0; bet = 1; }
void registerWin(const Hand & hand);
void registerBlackjack(const Hand & hand);
void registerLoss(const Hand & hand);
void registerPush(const Hand & hand);
virtual void winAdjustBet() {};
virtual void blackjackAdjustBet() {}
virtual void lossAdjustBet() {};
virtual void pushAdjustBet() {};
virtual bool takeEvenMoney() { return false; }
virtual int getInsuranceBet() { return 0; }
/* If a hand splits we must check more than one result */
using SubhandResults = std::vector<Hand>;
SubhandResults runHand(Hand hand, Card upcard) const;
virtual Decision makeDecision(const Hand & hand, Card upcard) const = 0;
virtual void countCards(const std::vector<Card> & cards) = 0;
};
Hand runDealer(Hand hand);
class SimplePlayer : public Player {
public:
SimplePlayer(std::string _name, int _bet) : Player(_name, _bet) {}
Decision makeDecision(const Hand & hand, Card upcard) const;
void countCards(const std::vector<Card> & cards) {}
};
class BasicPlayer : public Player {
public:
BasicPlayer(std::string _name, int _bet) : Player(_name, _bet) {}
Decision makeDecision(const Hand & hand, Card upcard) const;
virtual void countCards(const std::vector<Card> & cards) {}
};
class HiLoPlayer : public BasicPlayer {
public:
HiLoPlayer(std::string _name, int _bet) : BasicPlayer(_name, _bet) {}
void countCards(const std::vector<Card> & cards);
};
#endif // PLAYER_H_