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