• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

ksquares

  • sources
  • kde-4.14
  • kdegames
  • ksquares
  • src
ksquaresplayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2006 by Matthew Williams <matt@milliams.com> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 #ifndef KSQUARESPLAYER_H
11 #define KSQUARESPLAYER_H
12 
13 #include <QColor>
14 
23 class KSquaresPlayer
24 {
25  public:
33  explicit KSquaresPlayer(const QString &newName, const QColor &newColor, bool isPlayerHuman = true) {setName(newName); playerColour = newColor; human = isPlayerHuman; playerScore = 0;} //defaults to human player
34 
36  KSquaresPlayer() {} //Needed to do QVector<KSquaresPlayer>::operator[int i] since it has to allocate memory i think
37 
43  void setName(const QString &newName) {playerName = newName;}
44 
50  QString name() const {return playerName;}
51 
57  void setScore(int newScore) {playerScore = newScore;}
61  int score() const {return playerScore;}
63  void incScore() {playerScore++;}
64 
68  bool isHuman() const {return human;}
69 
73  QColor colour() const {return playerColour;}
74 
78  QString sig() const {return displaySig;}
79 
85  bool operator<(const KSquaresPlayer& player) const {return score() < player.score();}
86 
87  protected:
89  bool human;
91  int playerScore;
93  QString playerName;
95  QColor playerColour;
97  QString displaySig;
98 };
99 
100 #endif // KSQUARESPLAYER_H
KSquaresPlayer
Player class for KSquares.
Definition: ksquaresplayer.h:23
KSquaresPlayer::setName
void setName(const QString &newName)
Sets the players name.
Definition: ksquaresplayer.h:43
KSquaresPlayer::displaySig
QString displaySig
Letter (or two) to display on the board.
Definition: ksquaresplayer.h:97
KSquaresPlayer::setScore
void setScore(int newScore)
Sets the players score.
Definition: ksquaresplayer.h:57
KSquaresPlayer::KSquaresPlayer
KSquaresPlayer(const QString &newName, const QColor &newColor, bool isPlayerHuman=true)
Creates a player.
Definition: ksquaresplayer.h:33
KSquaresPlayer::playerColour
QColor playerColour
Player's display colour.
Definition: ksquaresplayer.h:95
KSquaresPlayer::sig
QString sig() const
Definition: ksquaresplayer.h:78
KSquaresPlayer::incScore
void incScore()
Increase the players score by 1.
Definition: ksquaresplayer.h:63
KSquaresPlayer::human
bool human
Is the player a human.
Definition: ksquaresplayer.h:89
QString
QColor
KSquaresPlayer::playerName
QString playerName
The player's displayable name.
Definition: ksquaresplayer.h:93
KSquaresPlayer::score
int score() const
Definition: ksquaresplayer.h:61
KSquaresPlayer::isHuman
bool isHuman() const
Definition: ksquaresplayer.h:68
KSquaresPlayer::playerScore
int playerScore
Player's current score.
Definition: ksquaresplayer.h:91
KSquaresPlayer::KSquaresPlayer
KSquaresPlayer()
Create a null player.
Definition: ksquaresplayer.h:36
KSquaresPlayer::operator<
bool operator<(const KSquaresPlayer &player) const
Used in sort algorithm.
Definition: ksquaresplayer.h:85
KSquaresPlayer::colour
QColor colour() const
Definition: ksquaresplayer.h:73
KSquaresPlayer::name
QString name() const
Sets the players name.
Definition: ksquaresplayer.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ksquares

Skip menu "ksquares"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal