diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-25 22:51:19 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-25 22:51:19 -0700 |
commit | fb4b69761ea08abdce119a0a2962ed475a348f42 (patch) | |
tree | c5de26b0063c2aabe2ff48e8fcbd435f68757b6c /web | |
parent | d242170ae6145907544e1605a94c540ad0390f31 (diff) | |
download | dartboat-fb4b69761ea08abdce119a0a2962ed475a348f42.tar.gz dartboat-fb4b69761ea08abdce119a0a2962ed475a348f42.tar.xz |
web: undo after num darts prompt should go back to num darts prompt
Diffstat (limited to 'web')
-rw-r--r-- | web/dartboat_wasm.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c index b44a9b8..d9c3540 100644 --- a/web/dartboat_wasm.c +++ b/web/dartboat_wasm.c @@ -24,7 +24,7 @@ struct match_state { struct leg *active_leg; int active_player; int boat_undone; - bool num_darts; + int num_darts; }; struct match_state *state; @@ -309,6 +309,17 @@ EMSCRIPTEN_KEEPALIVE void user_undo() return; } + if (state->num_darts) { + state->num_darts = 0; + EM_ASM({updatePlayerAvg($0, $1)}, state->active_player, + ((double)(state->active_leg->start - + state->active_leg->visits[ + state->active_leg->n_visits-2].rem) / + (state->active_leg->n_visits-1))); + handle_next(); + return; + } + if (state->mode == M_PVC) { set_active_player(1); } else if (state->mode == M_PVP) { @@ -322,7 +333,6 @@ EMSCRIPTEN_KEEPALIVE void user_undo() struct visit *v = l->visits + --l->n_visits; l->rem += v->points; memcpy(v, 0, sizeof(*v)); - state->num_darts = 0; if (state->mode == M_PVC && state->legs[1]->n_visits > l->n_visits) { state->legs[1]->rem += |