summaryrefslogtreecommitdiff
path: root/web/dartboat_wasm.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-23 21:36:10 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-23 21:36:10 -0700
commite3afbd56399e12beb37246a879dcf817de9b4ca1 (patch)
tree42d6492064a411450a1cf9ecea4aca0593d8a71d /web/dartboat_wasm.c
parente2fe11469394c9827a0cdea9966188c833d93197 (diff)
downloaddartboat-e3afbd56399e12beb37246a879dcf817de9b4ca1.tar.gz
dartboat-e3afbd56399e12beb37246a879dcf817de9b4ca1.tar.xz
web: allow undo for complete matches
Diffstat (limited to 'web/dartboat_wasm.c')
-rw-r--r--web/dartboat_wasm.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c
index 006ec1e..5aa38bc 100644
--- a/web/dartboat_wasm.c
+++ b/web/dartboat_wasm.c
@@ -274,13 +274,17 @@ EMSCRIPTEN_KEEPALIVE bool user_undo() {
return false;
}
- if (state->mode == M_PVP)
- switch_active_user();
+ if (state->mode == M_PVP) {
+ if (is_match_over())
+ EM_ASM({setPlayerActive($0)}, state->active_p);
+ else
+ switch_active_user();
+ }
struct leg *l = state->active_l;
struct visit *v = l->visits + --l->n_visits;
l->rem += v->points;
- if (state->mode == M_PVC) {
+ if (state->mode == M_PVC && state->l2->n_visits > l->n_visits) {
state->l2->rem += state->l2->visits[--state->l2->n_visits].points;
++state->undone_count;
}
@@ -297,6 +301,8 @@ EMSCRIPTEN_KEEPALIVE bool user_undo() {
memcpy(v, 0, sizeof(*v));
EM_ASM({clearVisits()});
+ EM_ASM({promptMsgR($0)}, "");
+ EM_ASM({setPromptHandler($0)}, "visit");
draw_match();
return true;