blob: 32523b61230037625fe1822af69ee36c1b17c19c (
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
60
61
62
|
#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 starting_player, active_player;
struct leg **legs;
};
struct leg *leg_init(int pts);
void leg_free(struct leg *l);
void leg_grow_visits(struct leg *l);
struct visit *leg_comp_visit(struct leg *l, bool redo_undone);
struct visit *leg_pts_visit(struct leg *l, int pts);
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_prev_throw_player(struct match *m);
int match_winning_player(struct match *m);
bool match_first_user_has_thrown(struct match *m);
bool is_points_valid(int pts, int rem);
#endif
|