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(); |