Skip to main content

nil_client/client/cheat/
npc.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::client::Client;
5use crate::error::Result;
6use crate::http;
7use nil_core::ethic::Ethics;
8use nil_core::npc::bot::BotId;
9use nil_payload::cheat::npc::*;
10
11impl Client {
12  pub async fn cheat_get_ethics(&self, req: CheatGetEthicsRequest) -> Result<Option<Ethics>> {
13    http::json_post("cheat-get-ethics")
14      .body(req)
15      .server(self.server)
16      .maybe_authorization(self.authorization.as_ref())
17      .user_agent(&self.user_agent)
18      .send()
19      .await
20  }
21
22  pub async fn cheat_set_bot_ethics(&self, req: CheatSetBotEthicsRequest) -> Result<()> {
23    http::post("cheat-set-bot-ethics")
24      .body(req)
25      .server(self.server)
26      .maybe_authorization(self.authorization.as_ref())
27      .user_agent(&self.user_agent)
28      .send()
29      .await
30  }
31
32  pub async fn cheat_spawn_bot(&self, req: CheatSpawnBotRequest) -> Result<BotId> {
33    http::json_post("cheat-spawn-bot")
34      .body(req)
35      .server(self.server)
36      .maybe_authorization(self.authorization.as_ref())
37      .user_agent(&self.user_agent)
38      .send()
39      .await
40  }
41}