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
11pub fn get_player(world: &World, id: &PlayerId) -> Result<Player> {
12  bail_if_cheats_are_not_allowed!(world);
13  world.player(id).cloned()
14}
15
16pub fn get_players(world: &World) -> Result<Vec<Player>> {
17  bail_if_cheats_are_not_allowed!(world);
18  world
19    .players()
20    .cloned()
21    .collect_vec()
22    .pipe(Ok)
23}