-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.c
44 lines (40 loc) · 1.24 KB
/
start.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <ncurses.h>
#include "print.h"
#include <stdlib.h>
#include "save.h"
#include "dice.h"
#include "menu.h"
#include "backgammon.h"
#include "structs.h"
#include "start.h"
#include "move.h"
void startGame(struct menu *menu, WINDOW *boardWindow, struct board *board) {
printMatchScore(board);
printBoard(boardWindow, board);
printDice((*board).move.moves, -1);
int winner;
if((winner = checkWinner(board)) != -1) showResults(boardWindow, board, menu, winner, 0);
else loadMenu(menu, playing);
}
void replayGame(struct menu *menu, WINDOW *boardWindow, struct board *board) {
int won[2];
won[0] = (*board).won[0];
won[1] = (*board).won[1];
loadBoard(BOARD_DEFAULT, board);
rollDice((*board).move.moves);
(*board).move.player = rand() % 2;
(*board).won[0] = won[0];
(*board).won[1] = won[1];
startGame(menu, boardWindow, board);
}
void startNewGame(struct menu *menu, WINDOW *boardWindow, struct board *board) {
loadBoard(BOARD_DEFAULT, board);
rollDice((*board).move.moves);
(*board).move.player = rand() % 2;
startGame(menu, boardWindow, board);
}
void promptLoadAndStart(struct menu *menu, WINDOW *boardWindow,
struct board *board) {
promptLoad(board);
startGame(menu, boardWindow, board);
}