summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-23 17:53:11 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-23 17:53:11 -0700
commitd31b800c35595428790905b21b771bbc187488ab (patch)
treea79f14318c2472fca4c545374664b3c6e79101a8 /web
parent9b7110d2652a18377bdd09094704188399bef0f8 (diff)
downloaddartboat-d31b800c35595428790905b21b771bbc187488ab.tar.gz
dartboat-d31b800c35595428790905b21b771bbc187488ab.tar.xz
web: fix undo state carrying over into next match
Diffstat (limited to 'web')
-rw-r--r--web/dartboat_wasm.c11
-rw-r--r--web/static/index.html2
-rw-r--r--web/static/style.css4
3 files changed, 9 insertions, 8 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c
index e624c67..9c838bd 100644
--- a/web/dartboat_wasm.c
+++ b/web/dartboat_wasm.c
@@ -17,11 +17,10 @@ int delay_ms = 1000;
struct match_state {
struct leg *l1, *l2;
+ int undone_count;
int complete;
};
-int undone_count = 0;
-
struct match_state *state;
void set_user_active() {
@@ -166,8 +165,8 @@ EMSCRIPTEN_KEEPALIVE void boat_visit() {
EM_ASM({promptMsgL($0)}, "Bot is throwing…");
struct leg *l = state->l2;
- if (undone_count) {
- --undone_count;
+ if (state->undone_count) {
+ --state->undone_count;
l->rem = l->visits[l->n_visits++].rem;
} else {
comp_visit(l);
@@ -253,7 +252,7 @@ EMSCRIPTEN_KEEPALIVE bool user_undo() {
struct visit *v = l->visits + --l->n_visits;
l->rem += v->points;
state->l2->rem += state->l2->visits[--state->l2->n_visits].points;
- ++undone_count;
+ ++state->undone_count;
EM_ASM({updatePlayerAvg($0, $1)}, P_USER,
l->n_visits ? (double)(l->start-l->rem)/l->n_visits : 0);
@@ -325,7 +324,7 @@ void init_boat() {
EMSCRIPTEN_KEEPALIVE void free_match() {
leg_free(state->l1);
- state->l2->n_visits += undone_count; // FIXME messy way to avoid memory leak
+ state->l2->n_visits += state->undone_count; // FIXME messy way to avoid memory leak
leg_free(state->l2);
free(state);
state = NULL;
diff --git a/web/static/index.html b/web/static/index.html
index d2d6bb4..dbd2b6e 100644
--- a/web/static/index.html
+++ b/web/static/index.html
@@ -44,7 +44,7 @@
<div onclick="promptHandle('append', 0)" class="key num">0</div>
<div onclick="promptHandle('submit')" class="key ok">OK</div>
<div onclick="promptHandle('undo')" class="key" id="key_undo">UNDO</div>
- <div onclick="promptHandle('submit_rem')" class="key">REM</div>
+ <div onclick="promptHandle('submit_rem')" class="key">REMAINING</div>
</div>
<div id="settings-bar">
<div>dartboat™</div>
diff --git a/web/static/style.css b/web/static/style.css
index b644439..397d5f8 100644
--- a/web/static/style.css
+++ b/web/static/style.css
@@ -40,7 +40,7 @@ div#oi {
visibility: hidden;
background-color: #6c0d0d;
- font-size: 2em;
+ font-size: 3em;
height: 1.2em;
width: 3ch;
@@ -190,6 +190,8 @@ div.key.num {
div.key.ok {
grid-row-end: span 2;
+
+ font-size: 2.5em;
}
div#settings-bar {