summaryrefslogtreecommitdiff
path: root/web/web_control.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/web_control.c')
-rw-r--r--web/web_control.c46
1 files changed, 6 insertions, 40 deletions
diff --git a/web/web_control.c b/web/web_control.c
index af5723a..4d62c05 100644
--- a/web/web_control.c
+++ b/web/web_control.c
@@ -28,11 +28,6 @@ void set_active_player(int pn)
prompt_visit();
}
-void toggle_active_player()
-{
- set_active_player(3 - state->active_player);
-}
-
void update_user_rem_from_pts(int pts)
{
update_player_rem(state->active_player, state_active_leg()->rem - pts);
@@ -144,7 +139,7 @@ void handle_next()
set_active_player(1);
} else {
if (state->active_player)
- toggle_active_player();
+ set_active_player(match_next_player());
else
set_active_player(match_opts->throws_first);
@@ -185,27 +180,11 @@ void user_visit_to_rem(int rem)
user_visit(state->legs[0]->rem - rem);
}
-static int prev_throw_player()
-{
- if (match_is_over())
- return state->active_player;
-
- if (state->active_player == 1)
- return match_num_players();
- else
- return state->active_player - 1;
-}
-
-static bool player_is_comp(int pn)
-{
- return state->mode == M_PVC && pn == 2;
-}
-
static void undo_active()
{
struct leg *l = state_active_leg();
- if (player_is_comp(state->active_player)) {
+ if (match_player_is_comp(state->active_player)) {
l->rem += l->visits[--l->n_visits].points;
++state->boat_undone;
} else {
@@ -217,25 +196,12 @@ static void undo_active()
update_player_avg(state->active_player, 0);
update_player_rem(state->active_player, l->rem);
- state->active_player = prev_throw_player();
-}
-
-static bool first_user_has_thrown() {
- for (int i = 0, np = match_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;
+ state->active_player = match_prev_throw_player();
}
void user_undo()
{
- if (!first_user_has_thrown()) {
+ if (!match_first_user_has_thrown()) {
oi();
return;
}
@@ -251,8 +217,8 @@ void user_undo()
return;
}
- state->active_player = prev_throw_player();
- while (player_is_comp(state->active_player))
+ state->active_player = match_prev_throw_player();
+ while (match_player_is_comp(state->active_player))
undo_active();
undo_active();