src/game.c

changeset 32
8a0b85303ee8
parent 31
ed440bcd9740
child 33
866025982aa9
equal deleted inserted replaced
31:ed440bcd9740 32:8a0b85303ee8
151 } 151 }
152 152
153 static int domove_singlemachine(GameState *gamestate, GameInfo *gameinfo) { 153 static int domove_singlemachine(GameState *gamestate, GameInfo *gameinfo) {
154 154
155 const size_t buflen = 8; 155 const size_t buflen = 8;
156 size_t bufpos = 0;
156 char movestr[buflen]; 157 char movestr[buflen];
157 movestr[0] = '\0';
158 158
159 int inputy = getmaxy(stdscr) - 6; 159 int inputy = getmaxy(stdscr) - 6;
160 while (1) { 160 while (1) {
161 draw_time(gamestate, gameinfo); 161 draw_time(gamestate, gameinfo);
162 move(inputy, 0); 162 move(inputy, 0);
165 "Or type 'surr' to surrender or 'remis' to end with remis.\n\n" 165 "Or type 'surr' to surrender or 'remis' to end with remis.\n\n"
166 "Type your move: "); 166 "Type your move: ");
167 clrtoeol(); 167 clrtoeol();
168 refresh(); 168 refresh();
169 169
170 if (asyncgetnstr(movestr, buflen)) { 170 if (asyncgetnstr(movestr, &bufpos, buflen)) {
171 if (strncmp(movestr, "surr", buflen) == 0) { 171 if (strncmp(movestr, "surr", buflen) == 0) {
172 printw("%s surrendered!", 172 printw("%s surrendered!",
173 gamestate->mycolor==WHITE?"White":"Black"); 173 gamestate->mycolor==WHITE?"White":"Black");
174 clrtoeol(); 174 clrtoeol();
175 refresh(); 175 refresh();
204 default: 204 default:
205 eval_move_failed_msg(eval_result); 205 eval_move_failed_msg(eval_result);
206 } 206 }
207 clrtoeol(); 207 clrtoeol();
208 } 208 }
209 movestr[0] = '\0'; /* reset string for next input */
210 } 209 }
211 } 210 }
212 } 211 }
213 212
214 static int sendmove(GameState *gamestate, int opponent) { 213 static int sendmove(GameState *gamestate, int opponent) {

mercurial