diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /ksame/StoneField.h | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksame/StoneField.h')
-rw-r--r-- | ksame/StoneField.h | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/ksame/StoneField.h b/ksame/StoneField.h new file mode 100644 index 00000000..df199605 --- /dev/null +++ b/ksame/StoneField.h @@ -0,0 +1,111 @@ +/* Yo Emacs, this is -*- C++ -*- */ +/* + * ksame 0.4 - simple Game + * Copyright (C) 1997,1998 Marcus Kreutzberger + * + * 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 _STONEFIELD +#define _STONEFIELD + +#include <krandomsequence.h> +#include <qptrlist.h> + +struct Stone { + unsigned char color; + bool changed; + bool marked; +}; + +class StoneField; +class StoneWidget; + +class StoneFieldState { +private: + unsigned char *field; + + int colors; + unsigned int board; + unsigned int score; + int gameover; + +public: + StoneFieldState(const StoneField &stonefield); + ~StoneFieldState(); + void restore(StoneField &stonefield) const; +}; + + +class StoneField { + friend class StoneFieldState; + friend class StoneWidget; +private: + + int sizex; + int sizey; + int maxstone; + + struct Stone *field; + + int colors; + unsigned int board; + unsigned int score; + mutable int gameover; + bool m_gotBonus; + int marked; + + KRandomSequence random; + QPtrList<StoneFieldState> *undolist; +public: + StoneField(int width=15,int height=10, + int colors=3,unsigned int board=0, + bool undoenabled=true); + ~StoneField(); + + 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 gotBonus() const; + bool undoPossible() const; + int getBoard() const; + int getScore() const; + int getColors() const; + int getMarked() const; + + int count(int color); +protected: + int getFieldSize() const; + struct Stone *getField() const; + + int map(int x,int y); + void mark(int index,unsigned char color); +}; + +#endif // _STONEFIELD + |