-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.h
115 lines (100 loc) · 2.91 KB
/
mainwindow.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
#include "playingcard.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
struct FullHand
{
int form = 0;
std::vector<SimpleCard> hi = {};
int rank = 0;
friend bool operator < (const FullHand& fh1, const FullHand& fh2)
{
if (fh1.form != fh2.form)
return fh1.form < fh2.form;
return fh1.hi < fh2.hi;
}
friend bool operator > (const FullHand& fh1, const FullHand& fh2)
{
if (fh1.form != fh2.form)
return fh1.form > fh2.form;
return fh1.hi > fh2.hi;
}
friend bool operator == (const FullHand& fh1, const FullHand& fh2)
{
return (fh1.form == fh2.form && fh1.hi == fh2.hi);
}
void addCards(std::vector<SimpleCard> newCards)
{
for (auto i : newCards)
hi.push_back(i);
}
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void ResetCards();
void SetButtonsEnabled(bool enabled);
void Flop();
void Turn();
void River();
void setMyBet(int _myBet);
void setComputerMoney(int _computerMoney);
void setMyMoney(int _myMoney);
void setComputerBet(int _computerBet);
void setPot(int _pot);
void RevealNextCards();
void FoldPlayer();
void FoldComputer();
void ComputerTurn();
void CallComputer();
void BetComputer(int bet);
void CheckComputer();
void HandleRound();
void Highlight(FullHand fh);
void SetTurn(int player);
int Evaluate(bool ai_generated);
void SimulateTurns(int nrTurns, int& wins, int& loses, int& draws);
FullHand CheckStraightFlush(bool player);
FullHand CheckQuads(bool player);
FullHand CheckFullHouse(bool player);
FullHand CheckFlush(bool player);
FullHand CheckStraight(bool player);
FullHand CheckTrips(bool player);
FullHand Check2Pairs(bool player);
FullHand CheckPair(bool player);
FullHand CheckHighCard(bool player);
void CheckForRestart();
void Manage(FullHand myResul, FullHand computerResult, bool ai_generated);
void getCards(bool (&card)[15][5], bool player);
void AddMoneyAnimation(QLabel* src, QLabel* dest, int transfer);
std::vector<SimpleCard> getHighestCards(bool (&card)[15][5], int k);
private slots:
void on_btnCall_clicked();
void on_btnAllIn_clicked();
void on_btnBet_clicked();
void on_btnFold_clicked();
void on_btnCheck_clicked(){};
private:
Ui::MainWindow *ui;
PlayingCard *centralCard[5];
PlayingCard *computerCard[2];
PlayingCard *myCard[2];
int pot = 0, myBet = 0, computerBet = 0;
int BB = 20, SB = 10;
int cardsToReveal = 3;
int rounds = 0;
int myMoney;
int computerMoney;
int winner = -1;
bool playerTurn = true;
int initComputerMoney;
int initMyMoney;
};
#endif // MAINWINDOW_H