1 #ifndef HEADER_RULES_H 2 #define HEADER_RULES_H 3 4 class V2; 5 class MarkMask; 6 class Field; 7 class OnCondition; 8 9 #include "NoCopy.h" 10 #include "Cube.h" 11 #include "Dir.h" 12 13 /** 14 * Game rules. 15 */ 16 class Rules : public NoCopy { 17 private: 18 Dir::eDir m_dir; 19 bool m_readyToDie; 20 bool m_readyToTurn; 21 bool m_readyToActive; 22 bool m_pushing; 23 bool m_lastFall; 24 int m_outDepth; 25 Dir::eDir m_touchDir; 26 27 Cube *m_model; 28 MarkMask *m_mask; 29 private: 30 bool checkDeadMove(); 31 bool checkDeadFall(); 32 bool checkDeadStress(); 33 34 bool isOnStack(); 35 bool isOnCond(const OnCondition &cond); 36 bool isOnWall(); 37 38 bool isOnHolderBacks(); 39 Cube::t_models getPads(); 40 bool isFalling() const; 41 Cube::t_models whoIsFalling(); 42 43 bool isHeavier(Cube::eWeight power) const; 44 Cube::t_models whoIsHeavier(Cube::eWeight power); 45 46 bool canDir(Dir::eDir dir, Cube::eWeight power); 47 bool touchSpec(Dir::eDir dir); 48 void setTouched(Dir::eDir dir); 49 void moveDirBrute(Dir::eDir dir); 50 public: 51 Rules(Cube *model); 52 ~Rules(); 53 void takeField(Field *field); 54 void change_setLocation(const V2 &loc); 55 56 void occupyNewPos(); 57 bool checkDead(Cube::eAction lastAction); 58 void changeState(); 59 void freeOldPos(); 60 61 int actionOut(); 62 void actionFall(); 63 bool clearLastFall(); 64 bool actionMoveDir(Dir::eDir dir); actionTurnSide()65 void actionTurnSide() { m_readyToTurn = true; } actionActivate()66 void actionActivate() { m_readyToActive = true; } 67 getDir()68 Dir::eDir getDir() const { return m_dir; } getTouchDir()69 Dir::eDir getTouchDir() const { return m_touchDir; } 70 std::string getAction() const; 71 std::string getState() const; 72 bool isOnStrongPad(Cube::eWeight weight); 73 bool isAtBorder() const; 74 bool isFreePlace(const V2 &loc) const; 75 const Cube::t_models getResist(Dir::eDir dir) const; isPushing()76 bool isPushing() const { return m_pushing; }; resetLastDir()77 void resetLastDir() { m_dir = Dir::DIR_NO; } 78 bool canMoveOthers(Dir::eDir dir, Cube::eWeight weight); 79 }; 80 81 #endif 82