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_put("cheat-get-ethics")
14      .body(req)
15      .server(self.server)
16      .maybe_authorization(self.authorization.as_ref())
17      .circuit_breaker(self.circuit_breaker())
18      .retry(&self.retry)
19      .user_agent(&self.user_agent)
20      .send()
21      .await
22  }
23
24  pub async fn cheat_set_bot_ethics(&self, req: CheatSetBotEthicsRequest) -> Result<()> {
25    http::post("cheat-set-bot-ethics")
26      .body(req)
27      .server(self.server)
28      .maybe_authorization(self.authorization.as_ref())
29      .circuit_breaker(self.circuit_breaker())
30      .user_agent(&self.user_agent)
31      .send()
32      .await
33  }
34
35  pub async fn cheat_spawn_bot(&self, req: CheatSpawnBotRequest) -> Result<BotId> {
36    http::json_post("cheat-spawn-bot")
37      .body(req)
38      .server(self.server)
39      .maybe_authorization(self.authorization.as_ref())
40      .circuit_breaker(self.circuit_breaker())
41      .user_agent(&self.user_agent)
42      .send()
43      .await
44  }
45}