-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTicTacToe.h
69 lines (50 loc) · 1.14 KB
/
TicTacToe.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
#ifndef TicTacToe_H
#define TicTacToe_H
#include <string>
#include <vector>
#include <map>
#define MAX_MOVES 9
typedef struct {
int r;
int c;
char s;
} Move;
typedef enum {
USER,
COMPUTER
} Player;
class TicTacToe {
public:
TicTacToe();
~TicTacToe();
void run();
private:
void clearBoard();
void drawBoard();
void drawBoard(int maskWin);
void sortPlayer();
void endGame();
bool wannaPlay();
bool gameOver();
Player getPlayer();
Move getUserMove();
Move getComputerMove();
void setMove(const Move &m, const Player &p);
bool checkMove(const Move &m);
bool checkWin(const Player &p);
bool checkMask(int movesPlayer, int mask);
void getPlayerInfo();
std::string getPlayerName(const Player &p);
int getRandomInt(int min, int max);
int getCoord(const std::string &coordType);
int m_countMoves = 0;
Move m_moves[MAX_MOVES];
bool m_play = true;
int m_sort = false;
std::map<Player, int> m_movesPlayer;
std::vector<int> m_movesAvailable;
std::string m_player_name = "";
char m_player_sym = '\0';
char m_computer_sym = '\0';
};
#endif