File indexing completed on 2024-11-24 03:46:29
0001 /* 0002 SPDX-FileCopyrightText: 1998 Anders Widell <d95-awi@nada.kth.se> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef LEVELMAP_H 0008 #define LEVELMAP_H 0009 0010 #include "Map.h" 0011 0012 #include <QString> 0013 0014 #include <cassert> 0015 0016 class LevelCollection; 0017 0018 class LevelMap 0019 { 0020 public: 0021 LevelMap(); 0022 ~LevelMap(); 0023 0024 public: 0025 LevelCollection *collection() const 0026 { 0027 return collection_; 0028 } 0029 const QString &collectionName() const; 0030 void changeCollection(LevelCollection *_collection); 0031 int totalMoves() const 0032 { 0033 return totalMoves_; 0034 } 0035 int totalPushes() const 0036 { 0037 return totalPushes_; 0038 } 0039 void level(int _level); 0040 int level() const; 0041 int noOfLevels() const; 0042 int completedLevels() const; 0043 bool goodLevel() const 0044 { 0045 return goodLevel_; 0046 } 0047 0048 bool step(int _x, int _y); 0049 bool push(int _x, int _y); 0050 bool unstep(int _x, int _y); 0051 bool unpush(int _x, int _y); 0052 int xpos() const 0053 { 0054 return map_.xpos(); 0055 } 0056 int ypos() const 0057 { 0058 return map_.ypos(); 0059 } 0060 bool completed() const 0061 { 0062 return map_.completed(); 0063 } 0064 0065 const Map& map() const 0066 { 0067 return map_; 0068 } 0069 0070 private: 0071 static int distance(int x1, int y1, int x2, int y2); 0072 0073 private: 0074 LevelCollection *collection_ = nullptr; 0075 0076 Map map_; 0077 int totalMoves_ = 0; 0078 int totalPushes_ = 0; 0079 bool goodLevel_ = false; 0080 }; 0081 0082 #endif /* LEVELMAP_H */