-
Notifications
You must be signed in to change notification settings - Fork 2
/
map.h
74 lines (52 loc) · 1.52 KB
/
map.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
#ifndef MAP_H
#define MAP_H
#include <QList>
#include <QObject>
#include <QPoint>
#include "tile.h"
class Player;
class Bomb;
class GameManager;
class Map : public QObject
{
Q_OBJECT
Q_PROPERTY(int width READ width() CONSTANT)
Q_PROPERTY(int height READ height() CONSTANT)
Q_PROPERTY(QList<QObject*> tiles READ tiles() CONSTANT)
Q_PROPERTY(QString name READ name() CONSTANT)
Q_PROPERTY(int maxPlayers READ maxPlayers() CONSTANT)
public:
explicit Map(GameManager *game, const QString &mapName);
int width() const;
int height() const;
bool isNull();
bool isValid();
QList<QObject*> tiles();
const QList<QPoint> &startingPositions() const;
bool isValidPosition(const QPoint &position) const;
bool isWithinBounds(const QPoint &position) const;
QString name() const;
int maxTicks() const { return m_maxTicks; }
int maxPlayers() const;
void addBomb(const QPoint &position, Player *player);
QList<Bomb*> bombs() const { return m_bombs; }
Tile *tileAt(const QPoint &position) const;
// For sudden death
void explodeEverything();
void addRandomBomb();
public slots:
void detonateBomb(const QPoint &position);
signals:
void explosionAt(QPoint position);
private:
bool explodeTile(const QPoint &position, Player *exploder);
int m_width;
int m_height;
int m_maxTicks;
QList<QObject*> m_tiles;
QList<QPoint> m_startingPositions;
QString m_name;
QList<Bomb*> m_bombs;
GameManager *m_game;
};
#endif // MAP_H