From de975396fe9eccd8f54c798b082c3d690b05c524 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 18 May 2022 15:59:48 -0700 Subject: web: change winning player message --- web/web_match.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'web/web_match.c') diff --git a/web/web_match.c b/web/web_match.c index b399b85..432808d 100644 --- a/web/web_match.c +++ b/web/web_match.c @@ -24,9 +24,27 @@ void match_opts_free() match_opts = NULL; } +int match_num_players() +{ + if (state->mode == M_P) + return 1; + + return 2; +} + +int match_winning_player() +{ + for (int i = 0; i < match_num_players(); ++i) { + if (state->legs[i]->rem == 0) + return i + 1; + } + + return -1; +} + bool match_is_over() { - return state->legs[0]->rem <= 0 || state->legs[1]->rem <= 0; + return match_winning_player() != -1; } struct leg *state_active_leg() -- cgit v1.2.3-70-g09d2