summaryrefslogtreecommitdiff
path: root/web/dartboat_wasm.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-24 01:52:28 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-04-24 01:52:28 -0700
commit3473a93fbb19846453d901505a720c2ccacb08d7 (patch)
tree6b6d6587da94b87da7f7d81cc986de9ce96b00bc /web/dartboat_wasm.c
parent3aa490e9cce29fd3d95eb0ce57b9744b3ed26516 (diff)
downloaddartboat-3473a93fbb19846453d901505a720c2ccacb08d7.tar.gz
dartboat-3473a93fbb19846453d901505a720c2ccacb08d7.tar.xz
web: minor style updates
Diffstat (limited to 'web/dartboat_wasm.c')
-rw-r--r--web/dartboat_wasm.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/web/dartboat_wasm.c b/web/dartboat_wasm.c
index 836c87f..1f81b1c 100644
--- a/web/dartboat_wasm.c
+++ b/web/dartboat_wasm.c
@@ -90,13 +90,16 @@ EMSCRIPTEN_KEEPALIVE void draw_match() {
struct leg *l2 = state->l2;
char visit_no[10], u_pts[10], u_rem[10], b_pts[10], b_rem[10], b_darts[100];
- visit_no[0] = u_pts[0] = u_rem[0] = b_pts[0] = b_rem[0] = b_darts[0] = 0;
+ sprintf(u_rem, "%d", l1->start);
+ sprintf(b_rem, "%d", l2->start);
EM_ASM({drawVisit($0, $1, $2, $3, $4, $5)},
- "0", "", "501", "", "501", "");
+ "0", "", u_rem, "", state->mode == M_P ? "" : b_rem, "");
int n_visits = l1->n_visits > l2->n_visits ? l1->n_visits : l2->n_visits;
for (int i = 0; i < n_visits; ++i) {
+ visit_no[0] = u_pts[0] = u_rem[0] = b_pts[0] = b_rem[0] = b_darts[0] = 0;
+
sprintf(visit_no, "%d", i + 1);
struct visit *v = l1->visits + i;
@@ -117,13 +120,6 @@ EMSCRIPTEN_KEEPALIVE void draw_match() {
EM_ASM({drawVisit($0, $1, $2, $3, $4, $5)},
visit_no, u_pts, u_rem, b_pts, b_rem, b_darts);
-
- visit_no[0] = 0;
- u_pts[0] = 0;
- u_rem[0] = 0;
- b_pts[0] = 0;
- b_rem[0] = 0;
- b_darts[0] = 0;
}
if (l1->rem <= 0) {
@@ -367,6 +363,7 @@ EMSCRIPTEN_KEEPALIVE void free_match() {
EMSCRIPTEN_KEEPALIVE void match_init() {
for (int i = 1; i < 3; ++i) {
+ EM_ASM({hidePlayerInfo($0)}, i);
EM_ASM({updatePlayerName($0, $1)}, i, "");
EM_ASM({updatePlayerRem($0, $1)}, i, "");
EM_ASM({updatePlayerSugg($0, $1)}, i, "");
@@ -397,10 +394,9 @@ EMSCRIPTEN_KEEPALIVE void start_match(int mode) {
state->l1 = leg_init(501, "Player 1");
state->l2 = leg_init(501, "Player 2");
}
- if (mode == M_P)
- EM_ASM(hidePlayer2());
- else
- EM_ASM(unhidePlayer2());
+ EM_ASM({showPlayerInfo($0)}, 1);
+ if (mode != M_P)
+ EM_ASM({showPlayerInfo($0)}, 2);
state->active_p = 1;
state->active_l = state->l1;