File indexing completed on 2024-02-18 04:04:52

0001 /*
0002     SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef ELEMENT_H
0008 #define ELEMENT_H
0009 
0010 #include "hitinfo.h"
0011 
0012 class Ship;
0013 
0014 class Element
0015 {
0016 public:
0017     enum Type
0018     {
0019         ALIVE,
0020         DEAD,
0021         MISS,
0022         BORDER,
0023         WATER
0024     };
0025 private:
0026     Ship* m_parent;
0027     Type m_type;
0028 public:
0029     Element(Type = WATER);
0030     explicit Element(Ship* parent);
0031     inline Ship* parent() { return m_parent; }
0032     inline const Ship* parent() const { return m_parent; }
0033     inline void setParent(Ship* ship) { m_parent = ship; }
0034     inline Type type() const { return m_type; }
0035     inline void setType(Type type) { m_type = type; }
0036     
0037     bool free() const;
0038     bool water() const;
0039     HitInfo::Type hit();
0040 };
0041 
0042 #endif // ELEMENT_H
0043