File indexing completed on 2024-05-19 04:04:47

0001 /*
0002     SPDX-FileCopyrightText: 2008 Sascha Peilicke <sasch.pe@gmx.de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef KIGO_STONE_H
0008 #define KIGO_STONE_H
0009 
0010 #include <QString>
0011 
0012 namespace Kigo {
0013 
0014 /**
0015  * This class represents a stone on a field of the game board.
0016  */
0017 class Stone
0018 {
0019 public:
0020     static Stone Pass;      ///< A standard pass move object
0021     static Stone Invalid;   ///< A standard invalid move object
0022 
0023     /**
0024      * Standard constructor. Can optionally set from the given coordinates.
0025      *
0026      * @param x The x coordinate of the stone
0027      * @param y The y coordinate of the stone
0028      * @param value The estimated quality of the move
0029      */
0030     explicit Stone(char x = 0, int y = 0, float value = 0);
0031 
0032     /**
0033      * Constructor to set from a stone given as a string.
0034      *
0035      * @param stone The stone as string
0036      * @param value The estimated quality of the move
0037      */
0038     explicit Stone(const QString &stone, float value = 0);
0039 
0040     Stone(const Stone &other);
0041     Stone &operator=(const Stone &other);
0042 
0043     bool isValid() const;
0044     QString toString() const;
0045     QByteArray toLatin1() const;
0046 
0047     char x() const { return m_x; }
0048     int y() const { return m_y; }
0049     float value() const { return m_value; }
0050 
0051 private:
0052     char m_x;           ///< The horizontal field coordinate (from 'A' to 'T')
0053     int m_y;            ///< The vertical field coordinate (from 1 to 19)
0054     float m_value;      ///< The estimated quality
0055 };
0056 
0057 QDebug operator<<(QDebug debug, const Stone &stone);
0058 
0059 bool operator==(const Stone &stone, const Stone &other);
0060 
0061 } // End of namespace Kigo
0062 
0063 #endif