(Temporarily) set "animate" to "none" by default (broken feature).
[gf1.git] / win_human.cxx
blobd07dfa957dedf56acd33ff64c34fa72fc83f9bb1
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 #include "win_human.h"
23 #include "callbacks.h"
25 #include <cstring>
27 void chartocolour (char c, char * str);
29 typedef struct {
30 char colour;
31 int game;
32 } human_info;
34 void * human_new (char colour, int game)
36 human_info * me;
38 me = (human_info *) malloc (sizeof (human_info));
39 me->colour = colour;
40 me->game = game;
42 return ((void *) me);
46 void human_move (board * oboard, void * self, float timeleft,
47 char * type, char * from, char * to)
49 #ifndef WINGIPF
50 human_info * me = (human_info *) self;
51 #endif
52 char buffer[10];
54 if (*type == 'g')
56 #ifndef WINGIPF
57 printf ("player %c, do you want to add a GIPF (y/n): ", me->colour);
58 gets (buffer);
59 if ((buffer[0] != 'y') && (buffer[0] != 'Y'))
61 *type = 'n';
63 #endif
66 buffer[0] = '\0';
67 while (strlen (buffer) < 5)
69 #ifndef WINGIPF
70 printf ("player %c, please enter your move (ex. h6-g6): ",
71 me->colour);
72 gets (buffer);
73 #endif
75 from[0] = buffer[0];
76 from[1] = buffer[1];
77 to[0] = buffer[3];
78 to[1] = buffer[4];
80 return;
84 char human_gipf (board * oboard, void * self, float timeleft, char * pos)
86 human_info * me = (human_info *) self;
87 char line1[100],
88 line2[100],
89 player[10];
90 int value;
92 chartocolour (me->colour, player);
93 sprintf (line1, "%s player, do you want to remove", player);
94 sprintf (line2, "the gipf at %s ?", pos);
95 value = gf1_question (line1, line2);
97 if (value)
99 return ('y');
101 else
103 return ('n');
108 char human_row (board * oboard, void * self, float timeleft,
109 char * start, char * end)
111 human_info * me = (human_info *) self;
112 char line1[100],
113 line2[100],
114 player[10];
115 int value;
117 chartocolour (me->colour, player);
118 sprintf (line1, "%s player, do you want to remove", player);
119 sprintf (line2, "the row from %s to %s ?", start, end);
120 value = gf1_question (line1, line2);
122 if (value)
124 return ('y');
126 else
128 return ('n');
133 void human_end (void * self)
135 human_info * me = (human_info *) self;
137 free (me);
138 return;
142 void chartocolour (char c, char * str)
144 if (c == 'o')
145 strcpy (str, "white");
146 else
147 strcpy (str, "black");
149 return;