1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/* ****************************************************************************
This file is part of the game 'KJumpingCube'
Copyright (C) 1998-2000 by Matthias Kiefer
<matthias.kiefer@gmx.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**************************************************************************** */
#ifndef KCUBEBOXWIDGET_H
#define KCUBEBOXWIDGET_H
#include "cubeboxbase.h"
#include "kcubewidget.h"
#include "brain.h"
#include <tqwidget.h>
class TQGridLayout;
class CubeBox;
class TQPalette;
class TQTimer;
class KConfigBase;
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/**
*@internal
*/
struct Loop
{
int row;
int column;
bool finished;
};
class KCubeBoxWidget : public TQWidget , public CubeBoxBase<KCubeWidget>
{
Q_OBJECT
TQ_OBJECT
public:
KCubeBoxWidget(const int dim=1,TQWidget *tqparent=0,const char *name=0);
KCubeBoxWidget(CubeBox& box, TQWidget *tqparent=0,const char *name=0);
KCubeBoxWidget(const KCubeBoxWidget& box,TQWidget *tqparent=0,const char *name=0);
virtual ~KCubeBoxWidget();
KCubeBoxWidget& operator= (CubeBox& box);
KCubeBoxWidget& operator= ( const KCubeBoxWidget& box);
/**
* reset cubebox for a new game
*/
void reset();
/** undo last move */
void undo();
/**
* set colors that are used to show owners of the cubes
*
* @param forWhom for which player the color should be set
* @param color color for player one
*/
void setColor(Player forWhom,TQPalette color);
/**
* sets number of Cubes in a row/column to 'size'.
*/
virtual void setDim(int dim);
/**
* sets player 'player' as computer or human
*
* @param player
* @param flag: true for computer, false for human
*/
void setComputerplayer(Player player,bool flag);
/** returns current skill, according to Prefs::EnumSkill */
int skill() const;
/** returns true if player 'player' is a computerPlayer */
bool isComputer(Player player) const;
/** returns true if CubeBox is doing a move or getting a hint */
bool isActive() const;
bool isMoving() const;
/** returns current Color for Player ´forWhom´ */
TQPalette color(Player forWhom);
/**
* checks if 'player' is a computerplayer an computes next move if TRUE
*/
void checkComputerplayer(Player player);
inline void saveGame(KConfigBase *c) { saveProperties(c); }
inline void restoreGame(KConfigBase *c) { readProperties(c); }
public slots:
/** stops all activities like getting a hint or doing a move */
void stopActivities();
/**
* computes a possibility to move and shows it by highlightning
* this cube
*/
void getHint();
void loadSettings();
signals:
void playerChanged(int newPlayer);
void playerWon(int player);
void startedMoving();
void startedThinking();
void stoppedMoving();
void stoppedThinking();
protected:
virtual TQSize tqsizeHint() const;
virtual void deleteCubes();
virtual void initCubes();
void saveProperties(KConfigBase *);
void readProperties(KConfigBase *);
protected slots:
/** sets the cursor to an waitcursor */
void setWaitCursor();
/** restores the original cursor */
void setNormalCursor();
private:
void init();
TQGridLayout *tqlayout;
CubeBox *undoBox;
Brain brain;
TQTimer *moveTimer;
int moveDelay;
Loop loop;
/** */
void startLoop();
/** */
void stopLoop();
Player changePlayer();
bool hasPlayerWon(Player player);
bool computerPlOne;
bool computerPlTwo;
/**
* increases the cube at row 'row' and column 'column' ,
* and starts the Loop for checking the playingfield
*/
void doMove(int row,int column);
void increaseNeighbours(KCubeBoxWidget::Player forWhom,int row,int column);
private slots:
void nextLoopStep();
/**
* checks if cube at ['row','column'] is clickable by the current player.
* if true, it increases this cube and checks the playingfield
*/
bool checkClick(int row,int column,bool isClick);
/** turns off blinking, if an other cube is clicked */
void stopHint();
};
#endif // KCUBEBOXWIDGET_H
|