blob: a699f7728d8186562563cf3fa6ee4999ec73dc7a (
plain) (
blame)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#ifndef MATCH_H
#define MATCH_H
#include "board.h"
#include <stdbool.h>
enum player_type {
PT_USER,
PT_COMP
};
struct player {
char *name;
enum player_type type;
};
struct visit {
int points;
int rem;
int n_darts;
struct segment *darts;
struct ccoords *ccoords;
};
struct leg {
int start, rem;
int n_visits, size_visits, undone_visits;
struct visit *visits;
};
struct match {
struct player *players;
int n_players, size_players;
int active_player;
struct leg **legs;
};
struct leg *leg_init(int points);
void leg_free(struct leg *l);
void leg_grow_visits(struct leg *l);
void leg_undo_visit(struct leg *l);
void leg_redo_visit(struct leg *l);
struct match *match_init();
void match_free(struct match *m);
void match_add_player(struct match *m, enum player_type type, char *name,
int start_pts);
int match_next_player(struct match *m);
int match_prev_player(struct match *m);
int match_last_player_to_throw(struct match *m);
int match_winning_player(struct match *m);
bool is_points_valid(int pts, int rem);
#endif
|