summaryrefslogtreecommitdiff
path: root/web/dartboat_wasm.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-21 11:10:22 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-21 11:10:22 -0700
commit0b02f05cdfa7ad6967557fa8228248ffabc515a2 (patch)
tree47bc2ad20fc2b1d9e9878492ba32fe472296be90 /web/dartboat_wasm.c
parentfc070779ba2a8a0668222dc7fd6fb39eb700d0bd (diff)
downloaddartboat-0b02f05cdfa7ad6967557fa8228248ffabc515a2.tar.gz
dartboat-0b02f05cdfa7ad6967557fa8228248ffabc515a2.tar.xz
redesign web interface; minor bug fixes
Diffstat (limited to 'web/dartboat_wasm.c')
-rw-r--r--web/dartboat_wasm.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c
index 3be713b..4eaa6ce 100644
--- a/web/dartboat_wasm.c
+++ b/web/dartboat_wasm.c
@@ -17,7 +17,7 @@ struct match_state {
void suggested(int rem, char *buf) {
buf[0] = 0;
- if (rem <= 170) {
+ if (rem > 1 && rem <= 170) {
char *target = CHECKOUTS[2][rem-1];
if (target) {
int trem = rem - segment_points(segment_from_name(target));
@@ -36,6 +36,16 @@ void suggested(int rem, char *buf) {
}
}
+EMSCRIPTEN_KEEPALIVE void get_suggested(int rem, int player) {
+ static char buf[20];
+ suggested(rem, buf);
+
+ if (player == 1)
+ EM_ASM({userSugg($0)}, buf);
+ else
+ EM_ASM({boatSugg($0)}, buf);
+}
+
EMSCRIPTEN_KEEPALIVE bool user_visit(struct match_state *state, int points) {
if (state->l1->rem <= 0 || state->l2->rem <= 0)
return false;
@@ -53,10 +63,6 @@ EMSCRIPTEN_KEEPALIVE bool user_visit(struct match_state *state, int points) {
v->rem = l->rem;
EM_ASM({updateUserRem($0)}, l->rem);
- char sug[100];
- suggested(v->rem, sug);
- EM_ASM({promptSugg($0)}, sug);
-
return true;
}
@@ -97,8 +103,6 @@ EMSCRIPTEN_KEEPALIVE void draw_match(struct match_state *state) {
char visit_no[10], u_pts[10], u_rem[10], b_pts[10], b_rem[10], b_darts[100];
visit_no[0] = u_pts[0] = u_rem[0] = b_pts[0] = b_rem[0] = b_darts[0] = 0;
- EM_ASM({drawVisitNames($0, $1)},
- l1->name, l2->name);
EM_ASM({drawVisit($0, $1, $2, $3, $4, $5)},
"0", "", "501", "", "501", "");
@@ -137,7 +141,6 @@ EMSCRIPTEN_KEEPALIVE void draw_match(struct match_state *state) {
EM_ASM({promptMsg($0)}, "You win! :)");
EM_ASM(matchOver());
} else if (l2->rem <= 0) {
- EM_ASM({promptSugg($0)}, "");
EM_ASM({promptMsg($0)}, "Bot wins. :(");
EM_ASM(matchOver());
} else {
@@ -177,7 +180,6 @@ EMSCRIPTEN_KEEPALIVE void free_match(struct match_state *state) {
}
EMSCRIPTEN_KEEPALIVE void change_stdev(float hstdev, float vstdev) {
- printf("%f %f\n", hstdev, vstdev);
horizontal_stdev = hstdev;
vertical_stdev = vstdev;
}