Skip to main content

nil_core/world/cheat/
player.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, PlayerId};
7use crate::world::World;
8use itertools::Itertools;
9use tap::Pipe;
10
11impl World {
12  pub fn cheat_get_player(&self, id: &PlayerId) -> Result<Player> {
13    bail_if_cheats_are_not_allowed!(self);
14    self.player(id).cloned()
15  }
16
17  pub fn cheat_get_players(&self) -> Result<Vec<Player>> {
18    bail_if_cheats_are_not_allowed!(self);
19    self
20      .players()
21      .cloned()
22      .collect_vec()
23      .pipe(Ok)
24  }
25}