summaryrefslogtreecommitdiff
path: root/web/web_match.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-01 15:07:11 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-01 15:07:11 -0700
commit22646d963e2b0c9b5ef629aa7704158026cfa6d1 (patch)
tree173473a78da784cf9a5e96770c5a87df5c575a8e /web/web_match.c
parent9459b7fb563caae520bdf8d11da9b070ebff45e9 (diff)
downloaddartboat-22646d963e2b0c9b5ef629aa7704158026cfa6d1.tar.gz
dartboat-22646d963e2b0c9b5ef629aa7704158026cfa6d1.tar.xz
web: split code into more files
This is currently very messy with all the files interdependent on one another and a lot of the logic still in the main file. It will take some time to refactor and clean up.
Diffstat (limited to 'web/web_match.c')
-rw-r--r--web/web_match.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/web/web_match.c b/web/web_match.c
new file mode 100644
index 0000000..47bc6e6
--- /dev/null
+++ b/web/web_match.c
@@ -0,0 +1,20 @@
+#include "web_match.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+struct match_state *state;
+
+void free_state()
+{
+ state->legs[1]->n_visits += state->boat_undone; // avoid memory leak
+ leg_free(state->legs[0]);
+ leg_free(state->legs[1]);
+ free(state);
+ state = NULL;
+}
+
+bool is_match_over()
+{
+ return state->legs[0]->rem <= 0 || state->legs[1]->rem <= 0;
+}