Diffstat (limited to 'noncore/games/zsame/StoneField.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/zsame/StoneField.h | 3 |
1 files changed, 2 insertions, 1 deletions
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 | |||
@@ -1,113 +1,114 @@ | |||
1 | /* Yo Emacs, this is -*- C++ -*- */ | 1 | /* Yo Emacs, this is -*- C++ -*- */ |
2 | /* | 2 | /* |
3 | * ksame 0.4 - simple Game | 3 | * ksame 0.4 - simple Game |
4 | * Copyright (C) 1997,1998 Marcus Kreutzberger | 4 | * Copyright (C) 1997,1998 Marcus Kreutzberger |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef _STONEFIELD | 22 | #ifndef _STONEFIELD |
23 | #define _STONEFIELD | 23 | #define _STONEFIELD |
24 | 24 | ||
25 | #include <krandomsequence.h> | 25 | #include <krandomsequence.h> |
26 | #include <qlist.h> | 26 | #include <qlist.h> |
27 | 27 | ||
28 | struct Stone { | 28 | struct Stone { |
29 | unsigned char color; | 29 | unsigned char color; |
30 | bool changed; | 30 | bool changed; |
31 | bool marked; | 31 | bool marked; |
32 | }; | 32 | }; |
33 | 33 | ||
34 | class StoneField; | 34 | class StoneField; |
35 | class StoneWidget; | 35 | class StoneWidget; |
36 | 36 | ||
37 | class StoneFieldState { | 37 | class StoneFieldState { |
38 | private: | 38 | private: |
39 | unsigned char *field; | 39 | unsigned char *field; |
40 | 40 | ||
41 | int colors; | 41 | int colors; |
42 | unsigned int board; | 42 | unsigned int board; |
43 | unsigned int score; | 43 | unsigned int score; |
44 | int gameover; | 44 | int gameover; |
45 | 45 | ||
46 | public: | 46 | public: |
47 | StoneFieldState(const StoneField &stonefield); | 47 | StoneFieldState(const StoneField &stonefield); |
48 | ~StoneFieldState(); | 48 | ~StoneFieldState(); |
49 | void restore(StoneField &stonefield) const; | 49 | void restore(StoneField &stonefield) const; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | 52 | ||
53 | class StoneField { | 53 | class StoneField { |
54 | friend class StoneFieldState; | 54 | friend class StoneFieldState; |
55 | friend class StoneWidget; | 55 | friend class StoneWidget; |
56 | private: | 56 | private: |
57 | 57 | ||
58 | int sizex; | 58 | int sizex; |
59 | int sizey; | 59 | int sizey; |
60 | int maxstone; | 60 | int maxstone; |
61 | 61 | ||
62 | struct Stone *field; | 62 | struct Stone *field; |
63 | 63 | ||
64 | int colors; | 64 | int colors; |
65 | unsigned int board; | 65 | unsigned int board; |
66 | unsigned int score; | 66 | unsigned int score; |
67 | mutable int gameover; | 67 | mutable int gameover; |
68 | bool m_gotBonus; | 68 | bool m_gotBonus; |
69 | int marked; | 69 | int marked; |
70 | 70 | ||
71 | KRandomSequence random; | 71 | KRandomSequence random; |
72 | QList<StoneFieldState> *undolist; | 72 | QList<StoneFieldState> *undolist; |
73 | public: | 73 | public: |
74 | StoneField(int width=15,int height=10, | 74 | StoneField(int width=15,int height=10, |
75 | int colors=3,unsigned int board=0, | 75 | int colors=3,unsigned int board=0, |
76 | bool undoenabled=true); | 76 | bool undoenabled=true); |
77 | ~StoneField(); | 77 | ~StoneField(); |
78 | 78 | ||
79 | int width() const; | 79 | int width() const; |
80 | int height() const; | 80 | int height() const; |
81 | 81 | ||
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); |
108 | }; | 109 | }; |
109 | 110 | ||
110 | #endif | 111 | #endif |
111 | 112 | ||
112 | 113 | ||
113 | 114 | ||