author | zecke <zecke> | 2004-10-15 01:48:45 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-15 01:48:45 (UTC) |
commit | fefeafe35f8dac30f4baab9e3bff8e2ffbd1afd0 (patch) (unidiff) | |
tree | a59a3bd9b5434657ee014dd6bbf7fbb50f5994d0 | |
parent | 85ab1a8cc3935538cc1f33fef7c94ba31accb53e (diff) | |
download | opie-fefeafe35f8dac30f4baab9e3bff8e2ffbd1afd0.zip opie-fefeafe35f8dac30f4baab9e3bff8e2ffbd1afd0.tar.gz opie-fefeafe35f8dac30f4baab9e3bff8e2ffbd1afd0.tar.bz2 |
Fix #1450 to clear the 'bonus' for removing every stone in the game
-rw-r--r-- | noncore/games/zsame/StoneField.cpp | 4 | ||||
-rw-r--r-- | noncore/games/zsame/StoneField.h | 3 | ||||
-rw-r--r-- | noncore/games/zsame/StoneWidget.cpp | 4 | ||||
-rw-r--r-- | noncore/games/zsame/StoneWidget.h | 1 | ||||
-rw-r--r-- | noncore/games/zsame/ZSameWidget.cpp | 1 |
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 | |||
@@ -343,24 +343,28 @@ StoneField::isGameover() const { | |||
343 | } | 343 | } |
344 | } | 344 | } |
345 | check_gameover: | 345 | check_gameover: |
346 | gameover=(i<0); | 346 | gameover=(i<0); |
347 | // kdDebug() << "<--gameover" << endl; | 347 | // kdDebug() << "<--gameover" << endl; |
348 | return (bool)gameover; | 348 | return (bool)gameover; |
349 | } | 349 | } |
350 | 350 | ||
351 | bool StoneField::gotBonus() const { | 351 | bool StoneField::gotBonus() const { |
352 | return m_gotBonus; | 352 | return m_gotBonus; |
353 | } | 353 | } |
354 | 354 | ||
355 | void StoneField::clearBonus() { | ||
356 | m_gotBonus = false; | ||
357 | } | ||
358 | |||
355 | int | 359 | int |
356 | StoneField::getBoard() const { | 360 | StoneField::getBoard() const { |
357 | return board; | 361 | return board; |
358 | } | 362 | } |
359 | 363 | ||
360 | int | 364 | int |
361 | StoneField::getScore() const { | 365 | StoneField::getScore() const { |
362 | return score; | 366 | return score; |
363 | } | 367 | } |
364 | 368 | ||
365 | int | 369 | int |
366 | StoneField::getColors() const { | 370 | StoneField::getColors() const { |
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 | |||
@@ -82,26 +82,27 @@ public: | |||
82 | void newGame(unsigned int board,int colors); | 82 | void newGame(unsigned int board,int colors); |
83 | 83 | ||
84 | void reset(); | 84 | void reset(); |
85 | 85 | ||
86 | 86 | ||
87 | int mark(int x,int y,bool force=false); | 87 | int mark(int x,int y,bool force=false); |
88 | void unmark(); | 88 | void unmark(); |
89 | 89 | ||
90 | int remove(int x,int y,bool force=false); | 90 | int remove(int x,int y,bool force=false); |
91 | 91 | ||
92 | int undo(int count=1); | 92 | int undo(int count=1); |
93 | 93 | ||
94 | bool isGameover() const; | 94 | bool isGameover() const; |
95 | bool gotBonus() const; | 95 | bool gotBonus() const; |
96 | void clearBonus(); | ||
96 | bool undoPossible() const; | 97 | bool undoPossible() const; |
97 | int getBoard() const; | 98 | int getBoard() const; |
98 | int getScore() const; | 99 | int getScore() const; |
99 | int getColors() const; | 100 | int getColors() const; |
100 | int getMarked() const; | 101 | int getMarked() const; |
101 | 102 | ||
102 | protected: | 103 | protected: |
103 | int getFieldSize() const; | 104 | int getFieldSize() const; |
104 | struct Stone *getField() const; | 105 | struct Stone *getField() const; |
105 | 106 | ||
106 | int map(int x,int y); | 107 | int map(int x,int y); |
107 | void mark(int index,unsigned char color); | 108 | void mark(int index,unsigned char color); |
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 | |||
@@ -176,24 +176,28 @@ StoneWidget::undo(int count) { | |||
176 | modified= (stonefield.getScore()>0); | 176 | modified= (stonefield.getScore()>0); |
177 | return ret_val; | 177 | return ret_val; |
178 | } | 178 | } |
179 | 179 | ||
180 | bool StoneWidget::isGameover() { | 180 | bool StoneWidget::isGameover() { |
181 | return stonefield.isGameover(); | 181 | return stonefield.isGameover(); |
182 | } | 182 | } |
183 | 183 | ||
184 | bool StoneWidget::hasBonus() { | 184 | bool StoneWidget::hasBonus() { |
185 | return stonefield.gotBonus(); // don't ask me why the names differ... ;-| [hlm] | 185 | return stonefield.gotBonus(); // don't ask me why the names differ... ;-| [hlm] |
186 | } | 186 | } |
187 | 187 | ||
188 | void StoneWidget::clearBonus() { | ||
189 | stonefield.clearBonus(); | ||
190 | } | ||
191 | |||
188 | bool StoneWidget::isOriginalBoard() { | 192 | bool StoneWidget::isOriginalBoard() { |
189 | return !modified; | 193 | return !modified; |
190 | } | 194 | } |
191 | 195 | ||
192 | void StoneWidget::readProperties(Config *) { | 196 | void StoneWidget::readProperties(Config *) { |
193 | /* Q_ASSERT(conf); | 197 | /* Q_ASSERT(conf); |
194 | 198 | ||
195 | history.clear(); | 199 | history.clear(); |
196 | 200 | ||
197 | if (!conf->hasKey("Board")|| | 201 | if (!conf->hasKey("Board")|| |
198 | !conf->hasKey("Colors")|| | 202 | !conf->hasKey("Colors")|| |
199 | !conf->hasKey("Stones")) { | 203 | !conf->hasKey("Stones")) { |
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 | |||
@@ -62,24 +62,25 @@ public: | |||
62 | 62 | ||
63 | bool undoPossible() const; | 63 | bool undoPossible() const; |
64 | 64 | ||
65 | void newGame(unsigned int board, int colors); | 65 | void newGame(unsigned int board, int colors); |
66 | void reset(); | 66 | void reset(); |
67 | void unmark(); | 67 | void unmark(); |
68 | int undo(int count=1); | 68 | int undo(int count=1); |
69 | 69 | ||
70 | // test for game end | 70 | // test for game end |
71 | bool isGameover(); | 71 | bool isGameover(); |
72 | // if isGameover(): finished with bonus? | 72 | // if isGameover(): finished with bonus? |
73 | bool hasBonus(); | 73 | bool hasBonus(); |
74 | void clearBonus(); | ||
74 | // test for unchanged start position | 75 | // test for unchanged start position |
75 | bool isOriginalBoard(); | 76 | bool isOriginalBoard(); |
76 | 77 | ||
77 | virtual void readProperties(Config *conf); | 78 | virtual void readProperties(Config *conf); |
78 | virtual void saveProperties(Config *conf); | 79 | virtual void saveProperties(Config *conf); |
79 | 80 | ||
80 | protected: | 81 | protected: |
81 | 82 | ||
82 | void timerEvent( QTimerEvent *e ); | 83 | void timerEvent( QTimerEvent *e ); |
83 | void paintEvent( QPaintEvent *e ); | 84 | void paintEvent( QPaintEvent *e ); |
84 | void mousePressEvent ( QMouseEvent *e); | 85 | void mousePressEvent ( QMouseEvent *e); |
85 | void myMoveEvent ( QMouseEvent *e); | 86 | void myMoveEvent ( QMouseEvent *e); |
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 | |||
@@ -209,24 +209,25 @@ void ZSameWidget::stonesRemoved(int,int) { | |||
209 | void ZSameWidget::setScore(int ) { | 209 | void ZSameWidget::setScore(int ) { |
210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); | 210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); |
211 | // undo->setEnabled(stone->undoPossible()); | 211 | // undo->setEnabled(stone->undoPossible()); |
212 | // restart->setEnabled(!stone->isOriginalBoard()); | 212 | // restart->setEnabled(!stone->isOriginalBoard()); |
213 | } | 213 | } |
214 | 214 | ||
215 | void ZSameWidget::gameover() { | 215 | void ZSameWidget::gameover() { |
216 | // kdDebug() << "GameOver" << endl; | 216 | // kdDebug() << "GameOver" << endl; |
217 | if (stone->hasBonus()) { | 217 | if (stone->hasBonus()) { |
218 | QMessageBox::information(this,i18n("Game won"), | 218 | QMessageBox::information(this,i18n("Game won"), |
219 | i18n("<qt>You even removed the last stone, great job! " | 219 | i18n("<qt>You even removed the last stone, great job! " |
220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); | 220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); |
221 | stone->clearBonus(); | ||
221 | } else { | 222 | } else { |
222 | QMessageBox::information(this,i18n("Game over"), | 223 | QMessageBox::information(this,i18n("Game over"), |
223 | i18n("<qt>There are no more removeable stones. " | 224 | i18n("<qt>There are no more removeable stones. " |
224 | "You got a score of %1 in total.</qt>").arg(stone->score())); | 225 | "You got a score of %1 in total.</qt>").arg(stone->score())); |
225 | } | 226 | } |
226 | stone->unmark(); | 227 | stone->unmark(); |
227 | } | 228 | } |
228 | 229 | ||
229 | void ZSameWidget::desktop_widget(int *f)const{ | 230 | void ZSameWidget::desktop_widget(int *f)const{ |
230 | 231 | ||
231 | QWidget* wid = QApplication::desktop(); | 232 | QWidget* wid = QApplication::desktop(); |
232 | /* width > height landscape mode */ | 233 | /* width > height landscape mode */ |