diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-18 02:04:55 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-18 02:04:55 -0700 |
commit | 46d5c38b80b2e5f6b237ea0313ba23c408bdf7fe (patch) | |
tree | 81f3b0f09f973d4f8bd8d2746a7dee776f4f57d0 /web | |
parent | 07478abb0796219ecd5c36a75c1fbb292909d089 (diff) | |
download | dartboat-46d5c38b80b2e5f6b237ea0313ba23c408bdf7fe.tar.gz dartboat-46d5c38b80b2e5f6b237ea0313ba23c408bdf7fe.tar.xz |
web: support first-visit undo when player 2 throws first
Diffstat (limited to 'web')
-rw-r--r-- | web/static/sw.js | 2 | ||||
-rw-r--r-- | web/web_control.c | 16 |
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; } |