From e3afbd56399e12beb37246a879dcf817de9b4ca1 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 23 Apr 2022 21:36:10 -0700 Subject: web: allow undo for complete matches --- web/dartboat_wasm.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'web/dartboat_wasm.c') 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; -- cgit v1.2.3-70-g09d2