341 memcpy(gamestate->board, initboard, sizeof(Board)); |
341 memcpy(gamestate->board, initboard, sizeof(Board)); |
342 } |
342 } |
343 |
343 |
344 void game_start_singlemachine(Settings *settings) { |
344 void game_start_singlemachine(Settings *settings) { |
345 GameState gamestate; |
345 GameState gamestate; |
|
346 memset(&gamestate, 0, sizeof(GameState)); |
346 init_board(&gamestate); |
347 init_board(&gamestate); |
347 gamestate.mycolor = WHITE; |
348 gamestate.mycolor = WHITE; |
348 gamestate.movelist = gamestate.lastmove = NULL; |
|
349 // TODO: time limit |
349 // TODO: time limit |
350 _Bool running; |
350 _Bool running; |
351 do { |
351 do { |
352 clear(); |
352 clear(); |
353 draw_board(&gamestate); |
353 draw_board(&gamestate); |
354 running = !domove_singlemachine(&gamestate); |
354 running = !domove_singlemachine(&gamestate); |
355 gamestate.mycolor = opponent_color(gamestate.mycolor); |
355 gamestate.mycolor = opponent_color(gamestate.mycolor); |
356 } while (running); |
356 } while (running); |
|
357 move(0,0); |
|
358 draw_board(&gamestate); |
357 |
359 |
358 gamestate_cleanup(&gamestate); |
360 gamestate_cleanup(&gamestate); |
359 |
361 |
360 mvaddstr(getmaxy(stdscr)-1, 0, |
362 mvaddstr(getmaxy(stdscr)-1, 0, |
361 "Game has ended. Press any key to leave..."); |
363 "Game has ended. Press any key to leave..."); |
367 _Bool myturn = is_server(settings) == |
369 _Bool myturn = is_server(settings) == |
368 (settings->gameinfo.servercolor == WHITE); |
370 (settings->gameinfo.servercolor == WHITE); |
369 |
371 |
370 // TODO: time limit |
372 // TODO: time limit |
371 GameState gamestate; |
373 GameState gamestate; |
|
374 memset(&gamestate, 0, sizeof(GameState)); |
372 init_board(&gamestate); |
375 init_board(&gamestate); |
373 gamestate.mycolor = myturn ? WHITE:BLACK; |
376 gamestate.mycolor = myturn ? WHITE:BLACK; |
374 gamestate.movelist = gamestate.lastmove = NULL; |
|
375 |
377 |
376 _Bool running; |
378 _Bool running; |
377 do { |
379 do { |
378 clear(); |
380 clear(); |
379 draw_board(&gamestate); |
381 draw_board(&gamestate); |
384 flushinp(); // flush any input the user hacked in while waiting |
386 flushinp(); // flush any input the user hacked in while waiting |
385 } |
387 } |
386 myturn ^= TRUE; |
388 myturn ^= TRUE; |
387 } while (running); |
389 } while (running); |
388 |
390 |
|
391 move(0,0); |
|
392 draw_board(&gamestate); |
|
393 |
389 gamestate_cleanup(&gamestate); |
394 gamestate_cleanup(&gamestate); |
390 |
395 |
391 mvaddstr(getmaxy(stdscr)-1, 0, |
396 mvaddstr(getmaxy(stdscr)-1, 0, |
392 "Game has ended. Press any key to leave..."); |
397 "Game has ended. Press any key to leave..."); |
393 refresh(); |
398 refresh(); |