summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/static/sw.js2
-rw-r--r--web/web_control.c16
2 files changed, 15 insertions, 3 deletions
diff --git a/web/static/sw.js b/web/static/sw.js
index 1844274..ac33994 100644
--- a/web/static/sw.js
+++ b/web/static/sw.js
@@ -1,5 +1,5 @@
const CACHE_PREFIX = 'dartboat-'
-const CACHE_VERSION = '14';
+const CACHE_VERSION = '15';
const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`;
const CACHE_FILES = [
diff --git a/web/web_control.c b/web/web_control.c
index fac1d8b..39b92ba 100644
--- a/web/web_control.c
+++ b/web/web_control.c
@@ -230,10 +230,22 @@ static void undo_active()
state->active_leg = state->legs[state->active_player - 1];
}
+static bool first_user_has_thrown() {
+ for (int i = 0, np = num_players(); i < np; ++i) {
+ int pn = match_opts->throws_first + i;
+ if (pn > np)
+ pn -= np;
+
+ if (!player_is_comp(pn))
+ return !!state->legs[pn - 1]->n_visits;
+ }
+
+ return false;
+}
+
void user_undo()
{
- // FIXME: undo doesn't work for first visit when player 2 throws first
- if (!state->legs[0]->n_visits) {
+ if (!first_user_has_thrown()) {
oi();
return;
}