Debian Codegraph @

src/player.h

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2004-2005 by Artur Wiebe *
3 * [email protected] *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #ifndef _PLAYER_H_
22 #define _PLAYER_H_
23
24 #include <QObject>
25
26
27 class Checkers;
28 class Field;
29
30
31 class myPlayer : public QObject
32 {
33 Q_OBJECT
34
35 public:
36 myPlayer(const QString& name, bool white)
37 : m_name(name), m_white(white), m_opponent(0) {}
38
39 // information
40 bool isWhite() const { return m_white; }
41 void setWhite(bool b) { m_white = b; }
42 //
43 const QString& name() const { return m_name; }
44 void setName(const QString& n) { m_name = n; }
45 //
46 virtual bool isHuman() const { return false; }
47
48 //
49 virtual void yourTurn(const Checkers* game) = 0;
50 // return false on incorrect course.
51 // set select to true to select the select, or unselect.
52 // QString contains error msg.
53 virtual bool fieldClicked(int, bool*, bool, QString&) { return true; }
54 // computerplayer terminates his thinking thread.
55 // humanplayer
56 // networkplayer disconnects from the server.
57 virtual void stop() = 0;
58
59 void setOpponent(myPlayer* o) { m_opponent=o; }
60 myPlayer* opponent() const { return m_opponent; }
61
62 signals:
63 // emitted when move is done, provides the complete board converted to
64 // string.
65 void moveDone(const QString&);
66
67 private:
68 QString m_name;
69 bool m_white;
70
71 myPlayer* m_opponent;
72 };
73
74
75 #endif