summaryrefslogtreecommitdiff
path: root/noncore/games/zsame/StoneField.h
Unidiff
Diffstat (limited to 'noncore/games/zsame/StoneField.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/zsame/StoneField.h113
1 files changed, 113 insertions, 0 deletions
diff --git a/noncore/games/zsame/StoneField.h b/noncore/games/zsame/StoneField.h
new file mode 100644
index 0000000..80be73a
--- a/dev/null
+++ b/noncore/games/zsame/StoneField.h
@@ -0,0 +1,113 @@
1/* Yo Emacs, this is -*- C++ -*- */
2/*
3 * ksame 0.4 - simple Game
4 * Copyright (C) 1997,1998 Marcus Kreutzberger
5 *
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
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
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
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 */
21
22#ifndef _STONEFIELD
23#define _STONEFIELD
24
25#include <krandomsequence.h>
26#include <qlist.h>
27
28struct Stone {
29 unsigned char color;
30 bool changed;
31 bool marked;
32};
33
34class StoneField;
35class StoneWidget;
36
37class StoneFieldState {
38private:
39 unsigned char *field;
40
41 int colors;
42 unsigned int board;
43 unsigned int score;
44 int gameover;
45
46public:
47 StoneFieldState(const StoneField &stonefield);
48 ~StoneFieldState();
49 void restore(StoneField &stonefield) const;
50};
51
52
53class StoneField {
54 friend class StoneFieldState;
55 friend class StoneWidget;
56private:
57
58 int sizex;
59 int sizey;
60 int maxstone;
61
62 struct Stone *field;
63
64 int colors;
65 unsigned int board;
66 unsigned int score;
67 mutable int gameover;
68 bool m_gotBonus;
69 int marked;
70
71 KRandomSequence random;
72 QList<StoneFieldState> *undolist;
73public:
74 StoneField(int width=15,int height=10,
75 int colors=3,unsigned int board=0,
76 bool undoenabled=true);
77 ~StoneField();
78
79 int width() const;
80 int height() const;
81
82 void newGame(unsigned int board,int colors);
83
84 void reset();
85
86
87 int mark(int x,int y,bool force=false);
88 void unmark();
89
90 int remove(int x,int y,bool force=false);
91
92 int undo(int count=1);
93
94 bool isGameover() const;
95 bool gotBonus() const;
96 bool undoPossible() const;
97 int getBoard() const;
98 int getScore() const;
99 int getColors() const;
100 int getMarked() const;
101
102protected:
103 int getFieldSize() const;
104 struct Stone *getField() const;
105
106 int map(int x,int y);
107 void mark(int index,unsigned char color);
108};
109
110#endif
111
112
113