diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-18 16:54:58 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-18 16:54:58 -0700 |
commit | 9ee81a83ee971b316446e337110d3bbfea7bfc8f (patch) | |
tree | 4e374d5f0dee387c2e0d8f9389aeefbc4fe935e3 | |
parent | 3fda7193b52eed1c724b6d5e5b8373c0a3fbf963 (diff) | |
download | dartboat-9ee81a83ee971b316446e337110d3bbfea7bfc8f.tar.gz dartboat-9ee81a83ee971b316446e337110d3bbfea7bfc8f.tar.xz |
web: use match info funcs instead of checking mode
-rw-r--r-- | web/static/sw.js | 2 | ||||
-rw-r--r-- | web/web_control.c | 24 | ||||
-rw-r--r-- | web/web_scoreboard.c | 6 |
3 files changed, 14 insertions, 18 deletions
diff --git a/web/static/sw.js b/web/static/sw.js index ac33994..f698a6d 100644 --- a/web/static/sw.js +++ b/web/static/sw.js @@ -1,5 +1,5 @@ const CACHE_PREFIX = 'dartboat-' -const CACHE_VERSION = '15'; +const CACHE_VERSION = '16'; const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`; const CACHE_FILES = [ diff --git a/web/web_control.c b/web/web_control.c index 4d62c05..c9fb138 100644 --- a/web/web_control.c +++ b/web/web_control.c @@ -22,7 +22,7 @@ void set_active_player(int pn) state->active_player = pn; scoreboard_set_player_active(pn); - if (state->mode == M_PVC && pn == 2) + if (match_player_is_comp(pn)) prompt_bot_visit(); else prompt_visit(); @@ -130,22 +130,18 @@ void handle_next() prompt_select_mode(); } else if (match_is_over()) { if (state->num_darts || - (state->mode == M_PVC && state->legs[1]->rem <= 0)) + match_player_is_comp(match_winning_player())) prompt_end_match(); else prompt_num_darts(); } else { - if (state->mode == M_P) { - set_active_player(1); - } else { - if (state->active_player) - set_active_player(match_next_player()); - else - set_active_player(match_opts->throws_first); - - if (state->mode == M_PVC && state->active_player == 2) - boat_visit(); - } + if (state->active_player) + set_active_player(match_next_player()); + else + set_active_player(match_opts->throws_first); + + if (match_player_is_comp(state->active_player)) + boat_visit(); } prompt_flush(); @@ -283,7 +279,7 @@ void start_match() update_player_rem(1, state->legs[0]->rem); update_player_avg(1, 0); - if (state->mode != M_P) { + if (match_num_players() != 1) { show_player_info(2); update_player_name(2, state->legs[1]->name); update_player_rem(2, state->legs[1]->rem); diff --git a/web/web_scoreboard.c b/web/web_scoreboard.c index 3b288c5..d1bfa7e 100644 --- a/web/web_scoreboard.c +++ b/web/web_scoreboard.c @@ -129,7 +129,7 @@ void update_player_rem(int pn, int rem) sprintf(str, "%d", rem); scoreboard_set_player_rem(pn, str); - if (pn == 1 || state->mode != M_PVC) + if (!match_player_is_comp(pn)) update_player_sugg(pn, rem); } @@ -178,7 +178,7 @@ void draw_visits() int elemc = 0; elemv[elemc++] = create_div(state->legs[0]->name, "visit-p1-name"); - if (state->mode != M_P) + if (match_num_players() != 1) elemv[elemc++] = create_div(state->legs[1]->name, "visit-p2-name"); @@ -189,7 +189,7 @@ void draw_visits() "visit-p1-pts throws-first icon"); elemv[elemc++] = create_div(buf, "visit-p1-rem"); elemv[elemc++] = create_div("0", "visit-n"); - if (state->mode != M_P) { + if (match_num_players() != 1) { snprintf(buf, sizeof(buf), "%d", state->legs[1]->start); elemv[elemc++] = create_div(buf, "visit-p2-rem"); if (match_opts->throws_first == 2) |