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/web_control.c | |
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/web_control.c')
-rw-r--r-- | web/web_control.c | 16 |
1 files changed, 14 insertions, 2 deletions
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; } |