(Temporarily) set "animate" to "none" by default (broken feature).
[gf1.git] / board.h
bloba67ce45dd4365ca54fe09275d514345906146e36
1 /*
2 ** $Id$
3 */
4 /*
5 ** Copyright (C) 1998 Kurt Van den Branden
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation; either version 2 of the License, or
10 ** (at your option) any later version.
11 **
12 ** This program is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with this program; if not, write to the Free Software
19 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef _BOARD_H_
23 #define _BOARD_H_ 1
25 #include <stdio.h>
26 #include <malloc.h>
27 #include "linklist.h"
28 #include "position.h"
29 #include "rem_gipf.h"
30 #include "rem_row.h"
31 #include "gamelog.h"
32 #include "xmlite.h"
34 typedef struct {
35 char pieces[8][9];
36 int status;
37 char nextpiece;
38 char winner;
39 char checkfour;
40 gamelog * log;
41 int movecounter;
42 listheader * gipfextra;
43 listheader * rowextraw;
44 listheader * rowextrab;
45 int white;
46 int lostwhite;
47 int gipfwhite;
48 char typewhite;
49 int black;
50 int lostblack;
51 int gipfblack;
52 char typeblack;
53 #ifdef WINGIPF
54 int removewait;
55 int animate;
56 #endif
57 } board;
58 #define b_newboard() (board *) malloc (sizeof (board))
60 /* struct for moves */
61 typedef struct {
62 char from[3];
63 char to[3];
64 char type;
65 } fromto;
67 /* lists with all possible moves */
68 extern fromto allmovesn[];
69 extern fromto allmovesg[];
71 /* all neighbours of board-positions */
72 extern unsigned char b_buren[9][9][6][2];
74 /* types of games */
75 #define T_BASIC 0
76 #define T_STANDARD 1
77 #define T_TOURNAMENT 2
78 #define T_OTHER 3 /* can not be used for b_new !! */
80 /* possible values for status */
81 #define S_NORMAL 0
82 #define S_REMOVEROW 1
83 #define S_REMOVEGIPF 2
84 #define S_FINISHED 3
86 /* some macro's for easy programming */
87 extern int _colsize[];
88 #define b_colsize(x) _colsize[x]
90 #define b_colnr(x) x - 'a'
92 extern char _colchar[];
93 #define b_colchar(x) _colchar[x]
95 #define b_opponent(x) (x == 'o'? 'x' : 'o')
97 #define b_otherpiece(x) (x=='o' ? 'O' : (x=='O' ? 'o' : (x=='x' ? 'X' : 'x')))
99 #define b_gipf_position(x) postostr (x->pos)
100 #define b_gipf_owner(x) x->owner
102 #define b_status(x) x->status
103 /*#define b_row_extra(x) x->rowextra*/
104 #define b_gipf_extra(x) x->gipfextra
105 #define b_white(x) x->white
106 #define b_white_gipf(x) x->gipfwhite
107 #define b_white_lost(x) x->lostwhite
108 #define b_black(x) x->black
109 #define b_black_gipf(x) x->gipfblack
110 #define b_black_lost(x) x->lostblack
111 #define b_next_piece(x) x->nextpiece
112 #define b_winner(x) x->winner
113 #define b_move_counter(x) x->movecounter
115 #define b_nolog(x) x->log = NULL
116 #define b_setlog(x,y) x->log = y
117 #define b_colour(x,y) (y == 'o' ? x->white : x->black)
118 #define b_colour_gipf(x,y) (y == 'o' ? x->gipfwhite : x->gipfblack)
119 #define b_colour_lost(x,y) (y == 'o' ? x->lostwhite : x->lostblack)
120 #define b_colour_type(x,y) (y == 'o' ? x->typewhite : x->typeblack)
122 /* this uses a position as second parameter instead of a string in b_piece */
123 #define b_ppiece(x, y) x->pieces[y->col][y->row]
125 #ifdef WINGIPF
126 #define setremovewait(x,y) x->removewait = y
127 #define setanimate(x,y) x->animate = y
128 #endif
130 /* real functions */
131 #ifdef __cplusplus
132 extern "C" {
133 #endif
134 board * b_new (int board_type);
135 board * b_copy (board * orig_board);
136 void b_print (board * boardp);
137 void b_del (board * dboard);
138 board * b_move (board * oboard, char * from, char * to, char npiece);
139 board * b_remove_row (board * oboard, int rownr);
140 board * b_remove_gipf (board * oboard, rem_gipf * rgipf);
141 board * b_checkfour (board * oboard);
142 rem_row * b_rowoffour (board * oboard, int rownr);
143 listheader * b_row_extra (board * oboard);
145 char b_piece (board * oboard, char * strpos);
146 int b_game_finished (board * oboard);
147 int b_compare (board * board1, board * board2);
148 board * b_edit_piece (board * oboard, position * pos, char piece);
149 board * b_edit_lostwhite (board * oboard, int newval);
150 board * b_edit_lostblack (board * oboard, int newval);
151 int b_to_file (board * oboard, FILE * fp);
152 board * b_from_file (FILE * fp);
153 xmlite_entity * b_to_xml (board * oboard);
154 board * b_from_xml (xmlite_entity * root);
156 #ifdef __cplusplus
158 #endif
160 #endif