Skip to main content

nil_core/world/cheat/
round.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::bail_if_cheats_are_not_allowed;
5use crate::error::Result;
6use crate::player::Player;
7use crate::world::World;
8use itertools::Itertools;
9use std::num::NonZeroU8;
10
11impl World {
12  pub fn cheat_skip_round(&mut self, amount: NonZeroU8) -> Result<()> {
13    bail_if_cheats_are_not_allowed!(self);
14
15    let amount = amount.get();
16    let players = self
17      .player_manager
18      .active_players()
19      .map(Player::id)
20      .collect_vec();
21
22    for i in 1..=amount {
23      for player in &players {
24        self.round.set_ready(player, true);
25      }
26
27      self.next_round(i == amount)?;
28    }
29
30    Ok(())
31  }
32}