-
Notifications
You must be signed in to change notification settings - Fork 0
/
Board.h
80 lines (72 loc) · 1.67 KB
/
Board.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
/*
* Board.h
*
* Created on: Feb 27, 2022
* Author: jacobadamsky
*/
#ifndef BOARD_H_
#define BOARD_H_
#include "Ship.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <list>
#include <conio.h>
#include <iostream>
#include <cstring>
#include <string>
#include <map>
#include <sys/time.h>
#include <chrono>
#include <thread>
namespace std {
struct WinPTS {
vector<int> pts = { 0, 8, 9 };
bool contains(int check) {
for (int num : pts) {
if (num == check) {
return true;
}
}
return false;
}
};
class Board {
public:
Board(int ROWS, int COLS) :
x(ROWS), y(COLS), playerBoard((int*)malloc(ROWS* COLS * sizeof(int))), compBoard((int*)malloc(ROWS* COLS * sizeof(int))) {
for (int num = 0; num < ROWS * COLS; num++) {
*(playerBoard + num) = 0;
*(compBoard + num) = 0;
}
}
virtual ~Board();
int x, y;
WinPTS winPTS;
int* playerBoard;
int* compBoard;
void printBoard(int*, bool comp);
void startGame();
map<int, int> indToSize = { { 1, 2 }, { 2, 3 }, { 3, 3 }, { 4, 4 }, { 5, 5 } };
std::vector<Pair> compPoints;
std::vector<Pair> playerGuessed;
std::vector<Pair> compGuessed;
std::vector<Ship> playerShips;
std::vector<Ship> compShips;
void getPlayerCoords(int i);
void addShip(Ship* ship);
void addCompShips(vector<Ship>& ships);
void genCompShips(int);
void setupCompShips();
void playerShoot();
void compShoot();
int checkWinner();
template<class T>
int vectorSize(vector<T> vector);
};
} /* namespace std */
#endif /* BOARD_H_ */