diff options
Diffstat (limited to 'web/web_match.c')
-rw-r--r-- | web/web_match.c | 20 |
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() |