1 /* 2 SPDX-FileCopyrightText: 2008 Sascha Peilicke <sasch.pe@gmx.de> 3 4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 5 */ 6 7 #ifndef KIGO_PLAYER_H 8 #define KIGO_PLAYER_H 9 10 #include <QString> 11 12 namespace Kigo { 13 14 /** 15 * The Player class holds all basic attributes of a Go player. These mean 16 * mostly name, skill and color. Instances are particular to a specific 17 * game and can thus only be created by the Go engine (Kigo::Game). 18 * 19 * @author Sascha Peilicke <sasch.pe@gmx.de> 20 * @since 0.5 21 */ 22 class Player 23 { 24 friend class Game; 25 26 public: 27 enum class Color { 28 White = 1, ///< The white player 29 Black, ///< The black player 30 Invalid 31 }; 32 33 enum class Type { 34 Human = 1, ///< A human player 35 Computer ///< A computer player 36 }; 37 38 private: 39 explicit Player(Color color, Type type = Type::Human); 40 41 public: 42 Player(const Player &other); 43 Player &operator=(const Player &other); 44 setName(const QString & name)45 void setName(const QString &name) { m_name = name; } name()46 QString name() const { return m_name; } 47 48 bool setStrength(int strength); strength()49 int strength() const { return m_strength; } 50 setColor(Color color)51 void setColor(Color color) { m_color = color; } color()52 Color color() const { return m_color; } 53 setType(Type type)54 void setType(Type type) { m_type = type; } type()55 Type type() const { return m_type; } 56 isWhite()57 bool isWhite() const { return m_color == Color::White; } isBlack()58 bool isBlack() const { return m_color == Color::Black; } isValid()59 bool isValid() const { return m_color != Color::Invalid; } isHuman()60 bool isHuman() const { return m_type == Type::Human; } isComputer()61 bool isComputer() const { return m_type == Type::Computer; } 62 63 bool operator==(const Player &other) const; 64 65 private: 66 QString m_name; 67 Color m_color; 68 Type m_type; 69 int m_strength; 70 }; 71 72 QDebug operator<<(QDebug debug, const Player &player); 73 74 } // End of namespace Kigo 75 76 #endif 77