summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/zsame/StoneField.cpp4
-rw-r--r--noncore/games/zsame/StoneField.h3
-rw-r--r--noncore/games/zsame/StoneWidget.cpp4
-rw-r--r--noncore/games/zsame/StoneWidget.h1
-rw-r--r--noncore/games/zsame/ZSameWidget.cpp1
5 files changed, 12 insertions, 1 deletions
diff --git a/noncore/games/zsame/StoneField.cpp b/noncore/games/zsame/StoneField.cpp
index 49d8eca..56e9dc5 100644
--- a/noncore/games/zsame/StoneField.cpp
+++ b/noncore/games/zsame/StoneField.cpp
@@ -339,32 +339,36 @@ StoneField::isGameover() const {
// check upward
if ( i>=sizex && field[i-sizex].color==color)
goto check_gameover;
i--;
}
}
check_gameover:
gameover=(i<0);
// kdDebug() << "<--gameover" << endl;
return (bool)gameover;
}
bool StoneField::gotBonus() const {
return m_gotBonus;
}
+void StoneField::clearBonus() {
+ m_gotBonus = false;
+}
+
int
StoneField::getBoard() const {
return board;
}
int
StoneField::getScore() const {
return score;
}
int
StoneField::getColors() const {
return colors;
}
int
diff --git a/noncore/games/zsame/StoneField.h b/noncore/games/zsame/StoneField.h
index 80be73a..d32d78d 100644
--- a/noncore/games/zsame/StoneField.h
+++ b/noncore/games/zsame/StoneField.h
@@ -78,34 +78,35 @@ public:
int width() const;
int height() const;
void newGame(unsigned int board,int colors);
void reset();
int mark(int x,int y,bool force=false);
void unmark();
int remove(int x,int y,bool force=false);
int undo(int count=1);
- bool isGameover() const;
+ bool isGameover() const;
bool gotBonus() const;
+ void clearBonus();
bool undoPossible() const;
int getBoard() const;
int getScore() const;
int getColors() const;
int getMarked() const;
protected:
int getFieldSize() const;
struct Stone *getField() const;
int map(int x,int y);
void mark(int index,unsigned char color);
};
#endif
diff --git a/noncore/games/zsame/StoneWidget.cpp b/noncore/games/zsame/StoneWidget.cpp
index 646fc9c..5dd0252 100644
--- a/noncore/games/zsame/StoneWidget.cpp
+++ b/noncore/games/zsame/StoneWidget.cpp
@@ -172,32 +172,36 @@ StoneWidget::undo(int count) {
int marked=stonefield.mark(x/stone_width,y/stone_height);
emit s_marked(marked);
slice=0;
emit s_score(stonefield.getScore());
modified= (stonefield.getScore()>0);
return ret_val;
}
bool StoneWidget::isGameover() {
return stonefield.isGameover();
}
bool StoneWidget::hasBonus() {
return stonefield.gotBonus(); // don't ask me why the names differ... ;-| [hlm]
}
+void StoneWidget::clearBonus() {
+ stonefield.clearBonus();
+}
+
bool StoneWidget::isOriginalBoard() {
return !modified;
}
void StoneWidget::readProperties(Config *) {
/* Q_ASSERT(conf);
history.clear();
if (!conf->hasKey("Board")||
!conf->hasKey("Colors")||
!conf->hasKey("Stones")) {
return;
}
newGame(conf->readNumEntry("Board"),conf->readNumEntry("Colors"));
diff --git a/noncore/games/zsame/StoneWidget.h b/noncore/games/zsame/StoneWidget.h
index 9cd7e10..89a8afc 100644
--- a/noncore/games/zsame/StoneWidget.h
+++ b/noncore/games/zsame/StoneWidget.h
@@ -58,32 +58,33 @@ public:
int marked();
QSize size();
int colors();
virtual QSize sizeHint() const;
bool undoPossible() const;
void newGame(unsigned int board, int colors);
void reset();
void unmark();
int undo(int count=1);
// test for game end
bool isGameover();
// if isGameover(): finished with bonus?
bool hasBonus();
+ void clearBonus();
// test for unchanged start position
bool isOriginalBoard();
virtual void readProperties(Config *conf);
virtual void saveProperties(Config *conf);
protected:
void timerEvent( QTimerEvent *e );
void paintEvent( QPaintEvent *e );
void mousePressEvent ( QMouseEvent *e);
void myMoveEvent ( QMouseEvent *e);
// properties of the stone picture
int stone_width,stone_height; // size of one stone
int maxcolors; // number of different stones (Y direction)
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp
index 04ad825..dee4a1c 100644
--- a/noncore/games/zsame/ZSameWidget.cpp
+++ b/noncore/games/zsame/ZSameWidget.cpp
@@ -205,32 +205,33 @@ void ZSameWidget::stonesRemoved(int,int) {
// KNotifyClient::event("stones removed",
// i18n("%1 stones removed.").arg(stone->marked()));
}
void ZSameWidget::setScore(int ) {
// status->changeItem(i18n("Score: %1").arg(score, 6),4);
// undo->setEnabled(stone->undoPossible());
// restart->setEnabled(!stone->isOriginalBoard());
}
void ZSameWidget::gameover() {
// kdDebug() << "GameOver" << endl;
if (stone->hasBonus()) {
QMessageBox::information(this,i18n("Game won"),
i18n("<qt>You even removed the last stone, great job! "
"This gave you a score of %1 in total.</qt>").arg(stone->score()));
+ stone->clearBonus();
} else {
QMessageBox::information(this,i18n("Game over"),
i18n("<qt>There are no more removeable stones. "
"You got a score of %1 in total.</qt>").arg(stone->score()));
}
stone->unmark();
}
void ZSameWidget::desktop_widget(int *f)const{
QWidget* wid = QApplication::desktop();
/* width > height landscape mode */
if ( wid->width() > wid->height() ) {
f[0]=15;
f[1]=9;
}