Skip to main content

nil_payload/request/
city.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use bon::Builder;
5use nil_core::city::CitySearch;
6use nil_core::continent::Coord;
7use nil_core::world::config::WorldId;
8use serde::{Deserialize, Serialize};
9
10#[cfg(feature = "typescript")]
11use ts_rs::TS;
12
13#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
14#[serde(rename_all = "camelCase")]
15#[cfg_attr(feature = "typescript", derive(TS))]
16#[cfg_attr(feature = "typescript", ts(export))]
17pub struct GetCityRequest {
18  #[builder(start_fn, into)]
19  pub world: WorldId,
20  #[builder(into)]
21  pub coord: Coord,
22}
23
24#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
25#[serde(rename_all = "camelCase")]
26#[cfg_attr(feature = "typescript", derive(TS))]
27#[cfg_attr(feature = "typescript", ts(export))]
28pub struct GetCityScoreRequest {
29  #[builder(start_fn, into)]
30  pub world: WorldId,
31  #[builder(into)]
32  pub coord: Coord,
33}
34
35#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
36#[serde(rename_all = "camelCase")]
37#[cfg_attr(feature = "typescript", derive(TS))]
38#[cfg_attr(feature = "typescript", ts(export))]
39pub struct GetPublicCitiesRequest {
40  #[builder(start_fn, into)]
41  pub world: WorldId,
42  #[serde(default)]
43  #[builder(default, with = FromIterator::from_iter)]
44  pub coords: Vec<Coord>,
45  #[serde(default)]
46  #[builder(default)]
47  pub score: bool,
48  #[serde(default)]
49  #[builder(default)]
50  pub all: bool,
51}
52
53#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
54#[serde(rename_all = "camelCase")]
55#[cfg_attr(feature = "typescript", derive(TS))]
56#[cfg_attr(feature = "typescript", ts(export))]
57pub struct GetPublicCityRequest {
58  #[builder(start_fn, into)]
59  pub world: WorldId,
60  #[builder(into)]
61  pub coord: Coord,
62  #[serde(default)]
63  #[builder(default)]
64  pub score: bool,
65}
66
67#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
68#[serde(rename_all = "camelCase")]
69#[cfg_attr(feature = "typescript", derive(TS))]
70#[cfg_attr(feature = "typescript", ts(export))]
71pub struct RenameCityRequest {
72  #[builder(start_fn, into)]
73  pub world: WorldId,
74  #[builder(into)]
75  pub coord: Coord,
76  #[builder(into)]
77  pub name: String,
78}
79
80#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
81#[serde(rename_all = "camelCase")]
82#[cfg_attr(feature = "typescript", derive(TS))]
83#[cfg_attr(feature = "typescript", ts(export))]
84pub struct SearchCityRequest {
85  #[builder(start_fn, into)]
86  pub world: WorldId,
87  #[builder(into)]
88  pub search: CitySearch,
89}
90
91#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
92#[serde(rename_all = "camelCase")]
93#[cfg_attr(feature = "typescript", derive(TS))]
94#[cfg_attr(feature = "typescript", ts(export))]
95pub struct SearchPublicCityRequest {
96  #[builder(start_fn, into)]
97  pub world: WorldId,
98  #[builder(into)]
99  pub search: CitySearch,
100}