From 0b02f05cdfa7ad6967557fa8228248ffabc515a2 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Thu, 21 Apr 2022 11:10:22 -0700 Subject: redesign web interface; minor bug fixes --- web/dartboat_wasm.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'web/dartboat_wasm.c') 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; } -- cgit v1.2.3-70-g09d2