-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlackJackStateMachine.h
49 lines (33 loc) · 1.04 KB
/
BlackJackStateMachine.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
#ifndef BLACKJACKSTATEMACHINE_H
#define BLACKJACKSTATEMACHINE_H
#include "GameStates.h"
#include "Card.h"
#include <QObject>
class BlackJackStateMachine : public QObject
{
Q_OBJECT
public:
static BlackJackStateMachine* instance( )
{
if(instance_ == nullptr) instance_ = new BlackJackStateMachine();
return instance_;
}
// This statemachine's primary concern is returning the state after
// a change occurs.
gameStates state() const;
int playerValue() const;
int dealerValue() const;
signals:
void stateChanged(gameStates state);
public slots:
void calcState(QSet<Card*> playerCards, QSet<Card*> dealerCards);
void calcState(QSet<Card*> playerCards, QSet<Card*> dealerCards, bool callGame);
private:
BlackJackStateMachine(QObject *parent = 0);
virtual ~BlackJackStateMachine();
static BlackJackStateMachine* instance_;
gameStates state_;
void calcValue(QSet<Card *> &container, int &value);
int playerValue_, dealerValue_;
};
#endif // BLACKJACKSTATEMACHINE_H