File indexing completed on 2024-04-28 04:01:50

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef CELL_H
0008 #define CELL_H
0009 
0010 #include <QtTypes>
0011 
0012 class Element;
0013 
0014 /**
0015  * @brief This class represents a Cell of the Maze.
0016  */
0017 class Cell
0018 {
0019 public:
0020     /** The Cell side size */
0021     static const qreal SIZE;
0022 
0023     /** The Cell possible types */
0024     enum Type { WALL = 0, CORRIDOR = 1, GHOSTCAMP = 2 };
0025 
0026 private:
0027     /** The Cell type */
0028     Type m_type;
0029 
0030     /** A reference on the Element that is on the Cell */
0031     Element *m_element;
0032 
0033     /** Cost used in A* pathfinding algorithm : lower is the cost, closer to the target Cell is this Cell */
0034     int m_cost;
0035 
0036     /** Parent node used in A* pathfinding algorithm : the Cell which enables to go to this Cell */
0037     Cell *m_parent;
0038 
0039 public:
0040     /**
0041      * Creates a new Cell instance.
0042      */
0043     Cell();
0044 
0045     /**
0046      * Deletes the Cell instance.
0047      */
0048     ~Cell();
0049 
0050     /**
0051      * Gets the Cell type.
0052      * @return the Cell type
0053      */
0054     Type getType() const;
0055 
0056     /**
0057      * Sets the Cell type.
0058      * @param p_type the new type to set
0059      */
0060     void setType(Type p_type);
0061 
0062     /**
0063      * Gets the Element that is on the Cell.
0064      * @return the Element that is on the Cell
0065      */
0066     Element *getElement() const;
0067 
0068     /**
0069      * Sets the Element that is on the Cell.
0070      * @param p_element the Element to set on the Cell
0071      */
0072     void setElement(Element *p_element);
0073 
0074     /**
0075      * Gets the Cell cost for A* pathfinding algorithm.
0076      * @return the Cell cost for A* pathfinding algorithm
0077      */
0078     int getCost() const;
0079 
0080     /**
0081      * Sets a cost for the Cell, for A* pathfinding algorithm.
0082      * @param p_cost the cost of the Cell for A* pathfinding algorithm
0083      */
0084     void setCost(const int p_cost);
0085 
0086     /**
0087      * Gets the parent Cell of this Cell for A* pathfinding algorithm.
0088      * @return the Cell parent for A* pathfinding algorithm
0089      */
0090     Cell *getParent() const;
0091 
0092     /**
0093      * Sets the parent Cell of this Cell for A* pathfinding algorithm.
0094      * @param p_parent the parent of the Cell for A* pathfinding algorithm
0095      */
0096     void setParent(Cell *p_parent);
0097 };
0098 
0099 #endif