diff options
Diffstat (limited to 'src/rounds.c')
| -rw-r--r-- | src/rounds.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/rounds.c b/src/rounds.c new file mode 100644 index 0000000..8db9ae8 --- /dev/null +++ b/src/rounds.c @@ -0,0 +1,35 @@ + +bool current_round_is_done() +{ + return _current_round.zombies == 0 && number_of_zombies_active() == 0; +} + +void start_next_round() +{ + _current_round.round_nr++; + _current_round.zombies = 6; + _current_round.state = ROUND_SWITCHING; + _current_round.round_timer = 0.0f; + + log_infox("Next round: %d", _current_round.round_nr); +} + +int zombies_left_in_current_round() +{ + if (_current_round.state != ROUND_SPAWNING) return 0; + return _current_round.zombies; +} + +void update_round_server() +{ + _current_round.round_timer += SERVER_TICK_RATE; + if (_current_round.state == ROUND_SWITCHING) { + if (_current_round.round_timer >= ROUND_SWITCH_TIME) { + _current_round.state = ROUND_SPAWNING; + } + } + + if (current_round_is_done()) { + start_next_round(); + } +}
\ No newline at end of file |
