source: trunk/c_abi.h @ 14

Last change on this file since 14 was 5, checked in by jtv, 14 years ago

Implemented saving/restoring of game state

File size: 2.4 KB
Line 
1/*
2This file is part of libmines.
3
4Copyright (C) 2005, Jeroen T. Vermeulen <jtv@xs4all.nl>
5
6libmines is free software; you can redistribute it and/or modify it under the
7terms of the GNU General Public License as published by the Free Software
8Foundation; either version 2 of the License, or (at your option) any later
9version.
10
11libmines is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License along with
16libmines; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17Suite 330, Boston, MA  02111-1307  USA
18*/
19
20/* C API/ABI to C++ Minesweeper implementation
21 */
22#ifdef __cplusplus
23extern "C"
24{
25#endif
26
27typedef void Minefield;
28
29/** @brief Create minefield of given size.  Clean up with mines_close() later!
30 */
31Minefield *mines_init(int rows, int cols, int mines);
32
33/** @brief Reload game state from memory buffer filled by mines_save()
34 */
35Minefield *mines_load(const char buffer[]);
36
37/** @brief Save minefield to buffer (at least rows*cols+100 bytes large).
38 * @return Number of bytes of buffer space used (not including terminating zero)
39 */
40int mines_save(Minefield *, char buffer[]);
41
42/** @brief Maximum intelligence level implemented by current version
43 */
44int mines_max_intelligence(void);
45
46/** @brief Set intelligence level of game's "autocompletion"
47 */
48void mines_set_intelligence(Minefield *, int);
49
50/** @brief Clean up minefield created with mines_init()
51 */
52void mines_close(Minefield *);
53
54/** @brief User states that patch at given coordinates is clear or a mine
55 * @return Boolean: correctness of guess (or -1 on error)
56 */
57int mines_probe(Minefield *, int row, int col, int minedP);
58
59/** Number of moves made
60 */
61int mines_moves(const Minefield *);
62
63/** @brief Status of patch at given coordinates
64 *  @return '^' for unexplored water, '*' for a known mine, or a textual digit
65 * indicating the number of nearby mines
66 */
67char mines_at(const Minefield *, int row, int col);
68
69/** @brief Number of unmined fields still left to be uncovered
70 */
71int mines_togo(const Minefield *);
72
73/** @brief Number of rows in minefield
74 */
75int mines_rows(const Minefield *);
76
77/** @brief Number of columns in minefield
78 */
79int mines_cols(const Minefield *);
80
81#ifdef __cplusplus
82}
83#endif
84
Note: See TracBrowser for help on using the repository browser.