File indexing completed on 2025-03-23 06:54:31
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_PLAYER_H 0008 #define KIGO_PLAYER_H 0009 0010 #include <QString> 0011 0012 namespace Kigo { 0013 0014 /** 0015 * The Player class holds all basic attributes of a Go player. These mean 0016 * mostly name, skill and color. Instances are particular to a specific 0017 * game and can thus only be created by the Go engine (Kigo::Game). 0018 * 0019 * @author Sascha Peilicke <sasch.pe@gmx.de> 0020 * @since 0.5 0021 */ 0022 class Player 0023 { 0024 friend class Game; 0025 0026 public: 0027 enum class Color { 0028 White = 1, ///< The white player 0029 Black, ///< The black player 0030 Invalid 0031 }; 0032 0033 enum class Type { 0034 Human = 1, ///< A human player 0035 Computer ///< A computer player 0036 }; 0037 0038 private: 0039 explicit Player(Color color, Type type = Type::Human); 0040 0041 public: 0042 Player(const Player &other); 0043 Player &operator=(const Player &other); 0044 0045 void setName(const QString &name) { m_name = name; } 0046 QString name() const { return m_name; } 0047 0048 bool setStrength(int strength); 0049 int strength() const { return m_strength; } 0050 0051 void setColor(Color color) { m_color = color; } 0052 Color color() const { return m_color; } 0053 0054 void setType(Type type) { m_type = type; } 0055 Type type() const { return m_type; } 0056 0057 bool isWhite() const { return m_color == Color::White; } 0058 bool isBlack() const { return m_color == Color::Black; } 0059 bool isValid() const { return m_color != Color::Invalid; } 0060 bool isHuman() const { return m_type == Type::Human; } 0061 bool isComputer() const { return m_type == Type::Computer; } 0062 0063 bool operator==(const Player &other) const; 0064 0065 private: 0066 QString m_name; 0067 Color m_color; 0068 Type m_type; 0069 int m_strength; 0070 }; 0071 0072 QDebug operator<<(QDebug debug, const Player &player); 0073 0074 } // End of namespace Kigo 0075 0076 #endif