summaryrefslogtreecommitdiff
path: root/src/rounds.c
diff options
context:
space:
mode:
authorAldrik Ramaekers <aldrik@amftech.nl>2023-11-05 11:08:16 +0100
committerAldrik Ramaekers <aldrik@amftech.nl>2023-11-05 11:08:16 +0100
commit075335d187f45de7d002e3f44f6ec93b30abed78 (patch)
tree0326b8ef2b4b779f4a1eee10a62b1a803c6e19ba /src/rounds.c
parent2b23a7efd6cc4d55e10e01c978a3614e7b97c93c (diff)
rounds
Diffstat (limited to 'src/rounds.c')
-rw-r--r--src/rounds.c35
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