diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-20 12:36:08 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-04-20 12:36:08 -0700 |
commit | f5e11d2e665f412d659e4ca7b714e9be663e26d7 (patch) | |
tree | 70a534f5203d710104842a125291ebd644012c94 | |
parent | 05dd0652a768ac05740d1465d30e1792b874414f (diff) | |
download | dartboat-f5e11d2e665f412d659e4ca7b714e9be663e26d7.tar.gz dartboat-f5e11d2e665f412d659e4ca7b714e9be663e26d7.tar.xz |
bust on 1 remaining; show bust in remaining bar
-rw-r--r-- | web/dartboat_wasm.c | 7 | ||||
-rw-r--r-- | web/static/dartboat.js | 13 |
2 files changed, 13 insertions, 7 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c index f43afb0..3be713b 100644 --- a/web/dartboat_wasm.c +++ b/web/dartboat_wasm.c @@ -40,9 +40,10 @@ EMSCRIPTEN_KEEPALIVE bool user_visit(struct match_state *state, int points) { if (state->l1->rem <= 0 || state->l2->rem <= 0) return false; - if (points > state->l1->rem || points > 180 || points == 179 || - points == 178 || points == 176 || points == 175 || points == 173 || - points == 172 || points == 169 || points == 166 || points == 163) + if (points > state->l1->rem || state->l1->rem - points == 1 || + points > 180 || points == 179 || points == 178 || points == 176 || + points == 175 || points == 173 || points == 172 || points == 169 || + points == 166 || points == 163) return false; struct leg *l = state->l1; diff --git a/web/static/dartboat.js b/web/static/dartboat.js index b261f28..5eb3283 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -65,15 +65,20 @@ function promptSuggStr(str) { function promptUpdateRem() { let elem = document.getElementById('user-rem'); let pts = document.getElementById('prompt').textContent; - if (pts) - elem.textContent = `${user_rem} » ${user_rem - pts}`; - else + if (pts) { + let nrem = user_rem - pts; + let nrem_str = nrem < 0 || nrem == 1 ? "BUST" : nrem; + elem.textContent = `${user_rem} » ${nrem_str}`; + } else { elem.textContent = user_rem; + } } function boatTempRem(pts, str) { let elem = document.getElementById('boat-rem'); - elem.textContent = `${boat_rem - pts} « ${boat_rem}`; + let nrem = boat_rem - pts; + let nrem_str = nrem < 0 || nrem == 1 ? "BUST" : nrem; + elem.textContent = `${nrem_str} « ${boat_rem}`; document.getElementById('prompt').textContent = pts; promptSuggStr(str); |