-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseafield.h
73 lines (42 loc) · 1.77 KB
/
seafield.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
#ifndef SEAFIELD_H
#define SEAFIELD_H
#include "points.h"
#include "ships.h"
#include <QVector>
#include <QMultiMap>
class SeaField
{
public:
using Field = QVector<QVector<Point>>; //псевдоним поля для игры
SeaField(int _i, int _j);
~SeaField();
Point operator[](const int _i) const;
Point operator[](const Point&) const;
//управление точками
void setPoint(const Point&);
//index = row * GetRowCount() + column
void setPoint(const int index, bool fill = true);
bool checkPoint(const Point&, bool onlyHorizontal = 0, bool onlyVertical = 0) const;
const Point& getPoint(int row, int col) const;
int getPointCount(bool isFill = true) const;
//управление кораблями
bool CheckShip(const Ship&) const;
void SetShip(const Ship& someShip);
QList<Ship> getShip(const int lenghtOfShip = 0) const;
QMultiMap<int,Ship>* getShips(const int lenghtOfShip = 0);
bool FindShipByPoint(const Point& p, Ship* &Result) const;
uint getShipCount(bool OnlyLives = false) const;
//возвращает близлижайщие точки около корабля по границе с ним
QVector<Point> getArroundPoint(const Ship& someShip) const;
void scanShips();
void clear();
bool isNewShots(const Point &);
QVector<Point>& getShots() const { return *_shots; }
const int i; //кол-во строк
const int j; //кол-во столбцов
Field* _Field; //игровое поле
private:
QMultiMap<int,Ship>* _ships; //массив кораблей на поле
QVector<Point>* _shots; //массив обстреленных точек
};
#endif // SEAFIELD_H