From b67982a90f861ba29e41ed366a481af707bd1c79 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Fri, 13 May 2022 17:12:16 -0700 Subject: web: use icons for settings; misc changes --- web/static/fonts/bootstrap-icons-sub.woff2 | Bin 728 -> 1036 bytes web/static/index.html | 12 ++++++------ web/static/style.css | 3 ++- web/static/sw.js | 15 ++++++--------- web/web_control.c | 4 ++-- web/web_prompt.c | 6 +++--- web/web_scoreboard.c | 4 ++-- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/web/static/fonts/bootstrap-icons-sub.woff2 b/web/static/fonts/bootstrap-icons-sub.woff2 index 3f7ef9b..0d765be 100644 Binary files a/web/static/fonts/bootstrap-icons-sub.woff2 and b/web/static/fonts/bootstrap-icons-sub.woff2 differ diff --git a/web/static/index.html b/web/static/index.html index f3dd2ae..2ed654b 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -16,10 +16,10 @@
dartboat™
-
-
-
-
+
+
+
+
oi!
@@ -75,8 +75,8 @@

dartboat

dartboat uses an internal representation of a specification dartboard. Darts are thrown following a normal distribution, with the resultant coordinates used to calculate the segments in which they land. The idea is that this provides a more realistic opponent than picking points at random.

Settings

-

stdev — the standard deviation of the bot's throws in millimetres. A value of 24 translates to a three-dart average of roughly 35. A value of 13 would be a 65 average, and a value of 8 a 95 average.

-

delay — milliseconds it takes the bot to throw each dart.

+

(delay) — milliseconds it takes the computer to throw each dart.

+

(stdev) — the standard deviation of the computer's throws in millimetres. A value of 24 translates to a three-dart average of roughly 35. A value of 13 would be a 65 average, and a value of 8 a 95 average.

Interface

To avoid destructive actions being a misclick away, certain actions require two presses—one to activate the button and another to trigger it.

The controls are designed to be keyboard-friendly. The keys should be fairly intuitive for the most part.

diff --git a/web/static/style.css b/web/static/style.css index ce2df1a..0d2fbcd 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -60,6 +60,7 @@ body { .icon { font-family: 'bootstrap-icons-sub'; + vertical-align: -0.125em; } /* titlebar */ @@ -449,7 +450,7 @@ body { #visits .p140 { color: #20e018; } #visits .p180 { color: #20e018; font-weight: bold; } #visits .throws-first { color: #999; } -#visits .throws-first:before { content: '\f151'; font-size: 0.75em; } +#visits .throws-first:before { content: '\f151'; font-size: 0.6em; } #visits .visit-p1-name { grid-column: 1 / span 2; } #visits .visit-p2-name { grid-column: 4 / span 2; } #visits .visit-p1-pts { grid-column: 1; } diff --git a/web/static/sw.js b/web/static/sw.js index f5d699a..6359ae5 100644 --- a/web/static/sw.js +++ b/web/static/sw.js @@ -1,8 +1,8 @@ const CACHE_PREFIX = 'dartboat-' -const CACHE_VERSION = '3'; +const CACHE_VERSION = '4'; const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`; -const FILES = [ +const CACHE_FILES = [ './', 'style.css', 'dartboat.js', @@ -18,19 +18,16 @@ function swlog(str) { self.addEventListener('install', e => { swlog('installing'); - - e.waitUntil((async() => { + e.waitUntil((async () => { swlog(`initialising cache ${CACHE_NAME}`); const cache = await caches.open(CACHE_NAME); - await cache.addAll(FILES); + await cache.addAll(CACHE_FILES); })()); - - swlog('installed'); }); self.addEventListener('activate', e => { - e.waitUntil(caches.keys().then((keys) => { - return Promise.all(keys.map((k) => { + e.waitUntil(caches.keys().then(keys => { + return Promise.all(keys.map(k => { if (k === CACHE_NAME || !k.startsWith(CACHE_PREFIX)) return; diff --git a/web/web_control.c b/web/web_control.c index e75b703..6d61f5c 100644 --- a/web/web_control.c +++ b/web/web_control.c @@ -68,7 +68,7 @@ void draw_boat_throwing(int pts, char *str, double x, double y) free(str); prompt_flush(); - scoreboard_flush_player_info(2); // FIXME bot hard-coded as player 2 + scoreboard_flush_player_info(2); } void boat_visit() @@ -254,7 +254,7 @@ void match_mode_selected(int mode) // names need to be freed if we stop using string literals if (mode == M_PVC) { match_opts->p1_name = "User"; - match_opts->p2_name = "Bot"; + match_opts->p2_name = "Computer"; } else if (mode == M_P) { match_opts->p1_name = "Player 1"; match_opts->p2_name = NULL; diff --git a/web/web_prompt.c b/web/web_prompt.c index 9db4fdd..decc1c1 100644 --- a/web/web_prompt.c +++ b/web/web_prompt.c @@ -151,7 +151,7 @@ void prompt_visit() void prompt_bot_visit() { set_prompt_mode(PM_DARTBOARD); - prompt_set_msgl("Bot is throwing…"); + prompt_set_msgl("Computer is throwing…"); prompt_set_msgr(NULL); } @@ -171,7 +171,7 @@ void prompt_end_match() set_prompt_mode(PM_END_MATCH); prompt_set_msgl( state->mode == M_PVC && state->legs[1]->rem <= 0 ? - "Bot wins. :(" : "You win! :)"); + "Computer wins. :(" : "You win! :)"); prompt_set_msgr(NULL); dom_set_content("#key-submit", "END MATCH"); @@ -190,7 +190,7 @@ void prompt_select_mode() prompt_set_msgr(NULL); clear_list_opts(); - add_list_opt("Play against bot"); + add_list_opt("Play against computer"); add_list_opt("One-player scoreboard"); add_list_opt("Two-player scoreboard"); flush_list_opts(); diff --git a/web/web_scoreboard.c b/web/web_scoreboard.c index e90409c..4ca823a 100644 --- a/web/web_scoreboard.c +++ b/web/web_scoreboard.c @@ -193,8 +193,8 @@ void draw_visits() snprintf(buf, sizeof(buf), "%d", state->legs[1]->start); elemv[elemc++] = create_div(buf, "visit-p2-rem"); if (match_opts->throws_first == 2) - elemv[elemc++] = create_div("∗", - "visit-p2-pts throws-first"); + elemv[elemc++] = create_div("", + "visit-p2-pts throws-first icon"); } for (int i = 0; i < n_visits; ++i) { -- cgit v1.2.3-70-g09d2