File indexing completed on 2024-10-13 03:43:13

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003     SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef CELL_H
0009 #define CELL_H
0010 
0011 #include "element.h"
0012 
0013 #include <QList>
0014 
0015 /**
0016  * @brief This class represents a Cell of the Arena.
0017  */
0018 class Cell
0019 {
0020 private:
0021 
0022     /** The Cell type */
0023     Granatier::Cell::Type m_type;
0024 
0025     /** A list of references of all Elements that are on the Cell */
0026     QList<Element*> m_elements;
0027 
0028 public:
0029 
0030     /**
0031       * Creates a new Cell instance.
0032       */
0033     Cell();
0034 
0035     /**
0036       * Deletes the Cell instance.
0037       */
0038     ~Cell();
0039 
0040     /**
0041       * Returns if it is possible to move into the cell or not, because of a wall, bomb, etc.
0042       * @return true if it is possible to move into the cell
0043       */
0044     bool isWalkable(Element* p_element) const;
0045 
0046     /**
0047       * Gets the Cell type.
0048       * @return the Cell type
0049       */
0050     Granatier::Cell::Type getType() const;
0051 
0052     /**
0053       * Sets the Cell type.
0054       * @param p_type the new type to set
0055       */
0056     void setType(Granatier::Cell::Type p_type);
0057 
0058     /**
0059      * Gets all the Elements that are on the Cell.
0060      * @return the Elements that are on the Cell
0061      */
0062     QList <Element*> getElements() const;
0063 
0064     /**
0065      * Gets the Elements of Element::Type type that are on the Cell.
0066      * @return the Elements of Element::Type type that are on the Cell
0067      */
0068     QList <Element*> getElements(Granatier::Element::Type type) const;
0069 
0070     /**
0071       * Sets the Element that is on the Cell.
0072       * @param p_element the Element to set on the Cell
0073       */
0074     void setElement(Element* p_element);
0075 
0076     /**
0077       * Removes the Element that is on the Cell.
0078       * @param p_element the Element to remove from the Cell
0079       */
0080     void removeElement(Element* p_element);
0081 };
0082 
0083 #endif
0084