diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-02 08:18:23 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-02 08:18:23 -0700 |
commit | 09c23f60189223db58d98e49ee94df947667662d (patch) | |
tree | 3667f7639ab257e407cad689cbd4054dcc315e76 /web | |
parent | 6a4dd8790c5c98466087a5374611f72131eff958 (diff) | |
download | dartboat-09c23f60189223db58d98e49ee94df947667662d.tar.gz dartboat-09c23f60189223db58d98e49ee94df947667662d.tar.xz |
web: minor cleanup of prompt code
Diffstat (limited to 'web')
-rw-r--r-- | web/web_control.c | 15 | ||||
-rw-r--r-- | web/web_control.h | 4 | ||||
-rw-r--r-- | web/web_main.c | 1 | ||||
-rw-r--r-- | web/web_prompt.c | 16 | ||||
-rw-r--r-- | web/web_prompt.h | 5 |
5 files changed, 23 insertions, 18 deletions
diff --git a/web/web_control.c b/web/web_control.c index b1e20bc..13e37ec 100644 --- a/web/web_control.c +++ b/web/web_control.c @@ -18,16 +18,10 @@ void set_active_player(int pn) state->active_leg = state->legs[pn-1]; EM_ASM({setPlayerActive($0)}, pn); - if (state->mode == M_PVC && pn == 2) { - EM_ASM({promptMsgL($0)}, "Bot is throwing…"); - set_prompt_mode(PM_DARTBOARD); - } else { - EM_ASM({promptMsgL($0)}, "Enter points:"); - EM_ASM({setKeyLabel($0, $1)}, "submit", "OK"); - EM_ASM({setKeyLabel($0, $1)}, "rem", "REMAINING"); - set_prompt_mode(PM_VISIT); - } - EM_ASM({promptMsgR($0)}, ""); + if (state->mode == M_PVC && pn == 2) + prompt_bot_visit(); + else + prompt_visit(); } void toggle_active_player() @@ -167,6 +161,7 @@ void user_undo() state->active_leg->visits[ state->active_leg->n_visits-2].rem) / (state->active_leg->n_visits-1))); + EM_ASM({setPlayerActive($0)}, state->active_player); handle_next(); return; } diff --git a/web/web_control.h b/web/web_control.h index 33cbd2c..ddecac0 100644 --- a/web/web_control.h +++ b/web/web_control.h @@ -1,9 +1,6 @@ #ifndef WEB_CONTROL_H #define WEB_CONTROL_H -void set_active_player(int pn); -void toggle_active_player(); - void start_match(int mode); void end_match(); void user_visit(int points); @@ -11,7 +8,6 @@ void user_num_darts(int n); void user_undo(); void user_visit_to_rem(int rem); void update_user_rem_from_pts(int pts); -void end_boat_visit(int rem, double avg); void handle_next(); diff --git a/web/web_main.c b/web/web_main.c index 42535aa..50dd318 100644 --- a/web/web_main.c +++ b/web/web_main.c @@ -21,7 +21,6 @@ void init() EM_ASM({updateDelay($0)}, delay_ms); EM_ASM({updateStdev($0)}, horizontal_stdev); - set_prompt_mode(PM_VISIT); handle_next(); } diff --git a/web/web_prompt.c b/web/web_prompt.c index abc5a05..7f65f6d 100644 --- a/web/web_prompt.c +++ b/web/web_prompt.c @@ -23,6 +23,22 @@ void set_prompt_mode(enum prompt_mode mode) pm == PM_SELECT_MODE ? "select_mode" : "default"); } +void prompt_visit() +{ + set_prompt_mode(PM_VISIT); + EM_ASM({promptMsgL($0)}, "Enter points:"); + EM_ASM({promptMsgR($0)}, ""); + EM_ASM({setKeyLabel($0, $1)}, "submit", "OK"); + EM_ASM({setKeyLabel($0, $1)}, "rem", "REMAINING"); +} + +void prompt_bot_visit() +{ + set_prompt_mode(PM_DARTBOARD); + EM_ASM({promptMsgL($0)}, "Bot is throwing…"); + EM_ASM({promptMsgR($0)}, ""); +} + void prompt_num_darts() { set_prompt_mode(PM_NUM_DARTS); diff --git a/web/web_prompt.h b/web/web_prompt.h index e70f779..5afbaef 100644 --- a/web/web_prompt.h +++ b/web/web_prompt.h @@ -11,9 +11,8 @@ enum prompt_mode { extern enum prompt_mode pm; -void set_prompt_mode(enum prompt_mode mode); -void prompt_handle(char *command, char *data); - +void prompt_visit(); +void prompt_bot_visit(); void prompt_num_darts(); void prompt_end_match(); void prompt_select_mode(); |