#ifndef MAP_H #define MAP_H #include "base_types.h" // Maximum map is 65530 x 65530 because qHash may be repeat and towers has same Id /// TODO: fix cell type - must be a union of int and bit flags class Map : public QObject { Q_OBJECT public: enum CellType { Free = 0, // FIXME: not worked yet!! // FIXME: must add Free cell to all functions Player = 1, // use Player + playerId for multiplayer AlienPath = 1000, // use AlienPath + Player and + playerId PlayerTower = -1, // use PlayerTower - Player - playerId Wall = -1000, Start = 9999, Finish = 8888 }; // 0 - free for any player // 1 - free for player 1 // 2 - free for player 2 // 3 - -/- // 1001 - player 1, free, but it is alien path (for optimization) // 1001 - player 2, free, but it is alien path (for optimization) // 1003 - -/- // 9999 - start field // 8888 - finish field // -1 - tower on free cell // -2 - player 1 tower // -3 - player 2 tower // -4 - -/- // -1000 - it is wall or some place where you can't build any towers explicit Map(QByteArray data, QSize size, QString name, int maxPlayers, int image, QObject *parent = 0); bool addTowerOnMap(int playerId, QPoint pos); //bool isFreePlace(QPoint pos); void delTowerOnMap(int playerId, QPoint pos); void removeAliensPath(); QVector createPath(QPoint start, QPoint finish); QRect rect() const {return QRect(QPoint(),mapSize);} const QString &name() const {return mapName;} const QList &starts() const {return Starts;} const QList &finishs() const {return Finishs;} const QVector < QVector > &cells() const {return Cells;} int image() const {return imageType;} int maxPlayers() const {return players;} signals: void recreateAlienPath(bool * pathOK); public slots: void printMap(); private: QSize mapSize; QString mapName; int players; int imageType; QVector < QVector > Cells; QVector < QVector > TmpCells; QList Starts; QList Finishs; QVector invWaveTrace(QPoint finish, int cnt); int waveTrace(QPoint start, QPoint finish); bool isReachable(int playerId, QPoint pos); }; #endif // MAP_H