#ifndef MATCH_H #define MATCH_H #include "board.h" #include 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); void leg_undo_visit(struct leg *l); struct visit *leg_redo_visit(struct leg *l); struct visit *leg_comp_visit(struct leg *l, bool redo_undone); struct visit *leg_pts_visit(struct leg *l, int pts); 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