Skip to main content

nil_core/world/cheat/
npc.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::ethic::Ethics;
7use crate::infrastructure::Infrastructure;
8use crate::npc::bot::BotId;
9use crate::ruler::Ruler;
10use crate::world::World;
11
12impl World {
13  pub fn cheat_get_ethics(&self, ruler: &Ruler) -> Result<Option<Ethics>> {
14    bail_if_cheats_are_not_allowed!(self);
15    self.get_ethics(ruler)
16  }
17
18  pub fn cheat_set_bot_ethics(&mut self, id: &BotId, ethics: Ethics) -> Result<()> {
19    bail_if_cheats_are_not_allowed!(self);
20    *self.bot_mut(id)?.ethics_mut() = ethics;
21    Ok(())
22  }
23
24  pub fn cheat_spawn_bot(&mut self, name: &str, infrastructure: Infrastructure) -> Result<BotId> {
25    bail_if_cheats_are_not_allowed!(self);
26    self.spawn_bot(name, infrastructure)
27  }
28}