summaryrefslogtreecommitdiff
path: root/match.h
diff options
context:
space:
mode:
Diffstat (limited to 'match.h')
-rw-r--r--match.h41
1 files changed, 36 insertions, 5 deletions
diff --git a/match.h b/match.h
index ce52717..a699f77 100644
--- a/match.h
+++ b/match.h
@@ -3,6 +3,18 @@
#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;
@@ -12,17 +24,36 @@ struct visit {
};
struct leg {
- char *name;
- int start;
- int rem;
- int n_visits, size_visits;
+ int start, rem;
+ int n_visits, size_visits, undone_visits;
struct visit *visits;
};
-struct leg *leg_init(int points, char *name);
+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