Skip to main content

nil_client/client/cheat/
resources.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::resources::Resources;
8use nil_payload::cheat::resources::*;
9
10impl Client {
11  pub async fn cheat_get_resources(&self, req: CheatGetResourcesRequest) -> Result<Resources> {
12    http::json_post("cheat-get-resources")
13      .body(req)
14      .server(self.server)
15      .maybe_authorization(self.authorization.as_ref())
16      .user_agent(&self.user_agent)
17      .send()
18      .await
19  }
20
21  pub async fn cheat_set_food(&self, req: CheatSetFoodRequest) -> Result<()> {
22    http::post("cheat-set-food")
23      .body(req)
24      .server(self.server)
25      .maybe_authorization(self.authorization.as_ref())
26      .user_agent(&self.user_agent)
27      .send()
28      .await
29  }
30
31  pub async fn cheat_set_iron(&self, req: CheatSetIronRequest) -> Result<()> {
32    http::post("cheat-set-iron")
33      .body(req)
34      .server(self.server)
35      .maybe_authorization(self.authorization.as_ref())
36      .user_agent(&self.user_agent)
37      .send()
38      .await
39  }
40
41  pub async fn cheat_set_max_food(&self, req: CheatSetMaxFoodRequest) -> Result<()> {
42    http::post("cheat-set-max-food")
43      .body(req)
44      .server(self.server)
45      .maybe_authorization(self.authorization.as_ref())
46      .user_agent(&self.user_agent)
47      .send()
48      .await
49  }
50
51  pub async fn cheat_set_max_iron(&self, req: CheatSetMaxIronRequest) -> Result<()> {
52    http::post("cheat-set-max-iron")
53      .body(req)
54      .server(self.server)
55      .maybe_authorization(self.authorization.as_ref())
56      .user_agent(&self.user_agent)
57      .send()
58      .await
59  }
60
61  pub async fn cheat_set_max_resources(&self, req: CheatSetMaxResourcesRequest) -> Result<()> {
62    http::post("cheat-set-max-resources")
63      .body(req)
64      .server(self.server)
65      .maybe_authorization(self.authorization.as_ref())
66      .user_agent(&self.user_agent)
67      .send()
68      .await
69  }
70
71  pub async fn cheat_set_max_silo_resources(
72    &self,
73    req: CheatSetMaxSiloResourcesRequest,
74  ) -> Result<()> {
75    http::post("cheat-set-max-silo-resources")
76      .body(req)
77      .server(self.server)
78      .maybe_authorization(self.authorization.as_ref())
79      .user_agent(&self.user_agent)
80      .send()
81      .await
82  }
83
84  pub async fn cheat_set_max_stone(&self, req: CheatSetMaxStoneRequest) -> Result<()> {
85    http::post("cheat-set-max-stone")
86      .body(req)
87      .server(self.server)
88      .maybe_authorization(self.authorization.as_ref())
89      .user_agent(&self.user_agent)
90      .send()
91      .await
92  }
93
94  pub async fn cheat_set_max_warehouse_resources(
95    &self,
96    req: CheatSetMaxWarehouseResourcesRequest,
97  ) -> Result<()> {
98    http::post("cheat-set-max-warehouse-resources")
99      .body(req)
100      .server(self.server)
101      .maybe_authorization(self.authorization.as_ref())
102      .user_agent(&self.user_agent)
103      .send()
104      .await
105  }
106
107  pub async fn cheat_set_max_wood(&self, req: CheatSetMaxWoodRequest) -> Result<()> {
108    http::post("cheat-set-max-wood")
109      .body(req)
110      .server(self.server)
111      .maybe_authorization(self.authorization.as_ref())
112      .user_agent(&self.user_agent)
113      .send()
114      .await
115  }
116
117  pub async fn cheat_set_resources(&self, req: CheatSetResourcesRequest) -> Result<()> {
118    http::post("cheat-set-resources")
119      .body(req)
120      .server(self.server)
121      .maybe_authorization(self.authorization.as_ref())
122      .user_agent(&self.user_agent)
123      .send()
124      .await
125  }
126
127  pub async fn cheat_set_stone(&self, req: CheatSetStoneRequest) -> Result<()> {
128    http::post("cheat-set-stone")
129      .body(req)
130      .server(self.server)
131      .maybe_authorization(self.authorization.as_ref())
132      .user_agent(&self.user_agent)
133      .send()
134      .await
135  }
136
137  pub async fn cheat_set_wood(&self, req: CheatSetWoodRequest) -> Result<()> {
138    http::post("cheat-set-wood")
139      .body(req)
140      .server(self.server)
141      .maybe_authorization(self.authorization.as_ref())
142      .user_agent(&self.user_agent)
143      .send()
144      .await
145  }
146}