Skip to main content

nil_core/world/cheat/
behavior.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::behavior::build::{BUILD_TEMPLATE, BuildStep};
6use crate::continent::Coord;
7use crate::error::Result;
8use crate::world::World;
9use itertools::Itertools;
10use tap::Pipe;
11
12impl World {
13  pub fn cheat_get_build_steps(&self, coord: Coord) -> Result<Vec<BuildStep>> {
14    bail_if_cheats_are_not_allowed!(self);
15    let infrastructure = self.infrastructure(coord)?;
16    BUILD_TEMPLATE
17      .iter()
18      .filter(|step| !step.is_done(infrastructure))
19      .cloned()
20      .collect_vec()
21      .pipe(Ok)
22  }
23}