summaryrefslogtreecommitdiff
path: root/web/web_match.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-18 15:59:48 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2022-05-18 15:59:48 -0700
commitde975396fe9eccd8f54c798b082c3d690b05c524 (patch)
tree75e2c55fa290bd742ecc5643b26d4af4cc0c6823 /web/web_match.c
parentcbbb37271bdfd5b51824f8b5a3ee5354236beff0 (diff)
downloaddartboat-de975396fe9eccd8f54c798b082c3d690b05c524.tar.gz
dartboat-de975396fe9eccd8f54c798b082c3d690b05c524.tar.xz
web: change winning player message
Diffstat (limited to 'web/web_match.c')
-rw-r--r--web/web_match.c20
1 files changed, 19 insertions, 1 deletions
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()